web - Is it necessary to use a lock for the accept function when doing socket programming? -



web - Is it necessary to use a lock for the accept function when doing socket programming? -

i have created preforking web server creates server socket, binds it, listens address , port , preforks specified number of workers (child processes) deed workers serving client requests.

all workers inherit socket descriptor of parent server , utilize take client requests. kid processes run autonomous processes @ "parallel" , utilize take function server socket descriptor. have utilize lock , unlock mechanism take function when accepting client request or operating scheme me? thought here multiple processes utilize mutual server socket descriptor accepting client requests. have shield mutual exclusion mechanism avoid race conditions or deadlocks?

please take business relationship utilize i/o nonblocking in take function.

i have next code:

for(;;) { int client = accept(...); if (client < 0) continue; ... }

should utilize like:

for(;;) { lock(); int client = accept(...); unlock(); if (client < 0) continue; ... }

??

no. it's scheme call, , hence atomic.

sockets web tcp preforking

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -