mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
remove-last-fork.patch
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
4f3943a8f8
commit
05464c6b7b
2 changed files with 13 additions and 22 deletions
|
@ -124,13 +124,22 @@ libwebsocket_close_and_free_session(struct libwebsocket *wsi)
|
|||
* @gid: group id to change to after setting listen socket, or -1.
|
||||
* @uid: user id to change to after setting listen socket, or -1.
|
||||
*
|
||||
* This function forks to create the listening socket and takes care
|
||||
* This function creates the listening socket and takes care
|
||||
* of all initialization in one step.
|
||||
*
|
||||
* It does not return since it sits in a service loop and operates via the
|
||||
* callbacks given in @protocol. User code should fork before calling
|
||||
* libwebsocket_create_server() if it wants to do other things in
|
||||
* parallel other than serve websockets.
|
||||
*
|
||||
* The callback function is called for a handful of events including
|
||||
* http requests coming in, websocket connections becoming
|
||||
* The protocol callback functions are called for a handful of events
|
||||
* including http requests coming in, websocket connections becoming
|
||||
* established, and data arriving; it's also called periodically to allow
|
||||
* async transmission.
|
||||
*
|
||||
* HTTP requests are sent always to the FIRST protocol in @protocol, since
|
||||
* at that time websocket protocol has not been negotiated. Other
|
||||
* protocols after the first one never see any HTTP callack activity.
|
||||
*
|
||||
* The server created is a simple http server by default; part of the
|
||||
* websocket standard is upgrading this http connection to a websocket one.
|
||||
|
@ -246,19 +255,6 @@ int libwebsocket_create_server(int port,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* fork off a master server for this websocket server */
|
||||
|
||||
n = fork();
|
||||
if (n < 0) {
|
||||
fprintf(stderr, "Failed on forking server thread: %d\n", n);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* we are done as far as the caller is concerned */
|
||||
|
||||
if (n)
|
||||
return sockfd;
|
||||
|
||||
/* drop any root privs for this thread */
|
||||
|
||||
if (gid != -1)
|
||||
|
@ -270,7 +266,7 @@ int libwebsocket_create_server(int port,
|
|||
|
||||
/*
|
||||
* sit there listening for connects, accept and service connections
|
||||
* in a poll loop, without any further forking
|
||||
* in a poll loop, without any forking
|
||||
*/
|
||||
|
||||
listen(sockfd, 5);
|
||||
|
|
|
@ -173,11 +173,6 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "libwebsocket init failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* just sit there until killed */
|
||||
|
||||
while (1)
|
||||
sleep(10);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue