« first day (714 days earlier)      last day (4249 days later) » 

11:00 PM
Well it was what I always wanted to be when I was younger, someone who was really good at a large variety of subjects because I didn't enjoy the concept of "specialization" and "you have to pick one thing"
 
@Rapptz It is just a fun travel. I have nephews whose grandma told my nephews my explanations for their questions were no good because they are too sciency.
 
Hi
Anyone have experience with dlopen?
It can't seem to find my SO file no matter what I'm doing
"libCrossLibs.so: cannot open shared object file: No such file or directory"
 
@IDWMaster This is not a Q&A forum
Ask your question on the appropriate site and you will have your answer.
@Rapptz And for myself, I stood on the floor of CERN WA98 for a few months, The sign that said "Danger radiation. Please walk fast" that was fun.
 
11:15 PM
I am writing a web application in C.
For the challenge.
 
nice, what are you using?
 
qox
C standard library, POSIX, Mongoose and MongoDB.
 
well, it'll be the fastest web application. That's for sure. How's it going from a wanting to tear out your own hair point of view? :-p
 
qox
I’m not sure if it will be fast. My router is very inefficient.
I could cache the routes if it turns out to be too slow.
The router should also return 500 if the regex could not compile, but I am going to fix that later. Maybe with a stack trace.
 
well, some sort of DFA based router written in C is about as fast as you're going to get without caching
 
qox
11:30 PM
Also, I am bald so don't worry.
 
Immunity, nice one
 
qox
What is DFA? A kind of data structure?
 
One point first: you should probably pre-compile all your regexes beforehand
A DFA is a Deterministic Finite State Automiton, it's a mathematical model of how a computer can match a pattern.
 
qox
@Will I could do that. May not be a bad idea, since it also allows for custom flags being set in the call to regcomp.
 
They are what are created by regex engines, but you can also have them compiled into c code and similar
 
qox
11:34 PM
However, precompiled regexes would require complex code for the router. Currently, I define my routes like this (and I would like to keep it that way for maintainability reasons):
 
although I'm not sure how complex your syntax is for routing
 
qox
wn_route routes[] = {
    {GET, "^/$", &home_handler},
    {POST, "^/submit(/)?$", &submit_handler},
};
 
yeah
in that array you could also store a regex_t
and loop though the array and compile the string into a regex
 
qox
I could do that, but they will need to be initialized by a call to regcomp.
 
if you do that at statrup you don't have to recompile it for each page request
 
qox
11:35 PM
Hmm, a loop wouldn't be a bad idea.
 
you'd have to remember to free them all again on shutdown
you could do that with at_exit()
 
qox
wn_serve could do that. It is the function that starts the web server and calls wn_get_handler for each request.
 
yeah
or you could do it lazily on the call to the patter
*to the get handler method
if you haven't set it up yet, compile the regexes, otherwise skip the step
it's all about trading startup time against response time when it's up and running
 
qox
I'll do it that way. Compile once.
typedef struct {
    wn_method method;
    regex_t regex;
    wn_handler handler;
} wn_compiled_route;
wn_serve will then transform all routes from a wn_route to a wn_compiled_route once, and pass those to wn_get_handler.
 
nice
 
qox
11:44 PM
Fixed that, and it works.
 
Glad to hear it. How are you dealing with 500s at the moment
 
qox
500s?
 
You were mentioning that you would be returning HTTP 500 when there was no handler for the page
is that simply if (!get_handler()) error(500);
 
qox
No 404 when there was no handler (but that is handled by the server, not by wn_get_handler), 500 if the regex could not be compiled, but that issue is solved now; the server will simply refuse to start.
wn_get_handler simply returns NULL when no handler could be found. It should not return a handler for that (because if it would, it would violate SRP).
 

« first day (714 days earlier)      last day (4249 days later) »