little help here needed.
i've been developing this fastcgi app to run ontop of nginx. and so far i've been doing good (while writing a parser for GET requests), so i moved on to implementing a POST request parser (which is essentially the same as the GET one), got it into local variables.. and everything seems fine, except the fact that in the constant (fcgi_accept loop) my parser will only eat ANY (get/post) request ONLY ONCE - and after that terminates with a segfault.
now in order to parse the request i use strtok() function and basic strcmp() stuff from <string.h>
prototype of a request is name/value pair such as mine "method=name_of_it"
question is: has anyone ever encountered such kind of error, if you did (or did not) any ideas why this might be happening?!
btw, before integrating the POST request handler (two lines of code), everything seemed to work fine and the constant accept loop persisted its existence until "method=kill" was passed through!
any help would be appreciated!!
Don't know if this will help you or not, but did you account for the fact that strtok() will write data into the string it is working on (NULL char's)?
after running gdb found out that i get a segfault in strcmp() for some reason :/
right after commenting out all strcmp() cases - my program seems to work, but i'd like to use built-in functions, instead of writing my own or using non-native libraries..
@Adak yeah i know that strtok() can sometimes be somewhat dangerous, but i think its the only feasible solution i have ://
Are you passing strcmp() two pointers to strings that are properly terminated?
If so, then I'd re-think that "coincidence" that strtok() tears apart strings, and now strcmp(), which works on strings, is crashing.
You can always work at the char level and leave your original string unchanged. More than one way to skin ye old cat. :cool:
trying to find the quickest one :D
i want to move on with this stuff :)
anyways, i'll probably go with the old way - char-by-char... oh well
thanks on that mate!
Without the code, I don't understand how you expect us to help you :confused: