diff options
author | deva <deva> | 2005-06-19 11:44:14 +0000 |
---|---|---|
committer | deva <deva> | 2005-06-19 11:44:14 +0000 |
commit | 52fd913be8b044f1d064973c53b4467e5bd153fe (patch) | |
tree | 807ac3d85c9af0fe81bd88c22f6fe32c3c7af25b /src/miav_daemon.cc | |
parent | 60053525996c751ea9cdeddebbea8fa98e0c23a3 (diff) |
Cleaned up a log of logging.
Fixed server queue (shouldn't happen).
Added user and group lookup.
Diffstat (limited to 'src/miav_daemon.cc')
-rw-r--r-- | src/miav_daemon.cc | 59 |
1 files changed, 44 insertions, 15 deletions
diff --git a/src/miav_daemon.cc b/src/miav_daemon.cc index 520a2fb..b164e92 100644 --- a/src/miav_daemon.cc +++ b/src/miav_daemon.cc @@ -31,6 +31,11 @@ /* * $Log$ + * Revision 1.5 2005/06/19 11:44:14 deva + * Cleaned up a log of logging. + * Fixed server queue (shouldn't happen). + * Added user and group lookup. + * * Revision 1.4 2005/06/16 21:28:57 deva * Rewrote thread object * Fixed bug in mov_encoder (pushed read_sem too many times, whihc lead to @@ -78,26 +83,50 @@ int MiavDaemon::daemon_main() info.info("Listening on port %d", port); Socket *socket = new Socket(port, &info); + if(socket->hasError()) { + info.error("Listening socket has errors, quitting."); + delete socket; + return 1; + } + while(1) { Socket *csocket = new Socket(socket->slisten()); - if(csocket->isConnected()) { - childpid = fork(); + + if(socket->hasError()) { + info.error("Server socket has errors, quitting."); + delete csocket; + break; + } + + if(csocket->hasError()) { + info.error("Child socket has errors, quitting."); + delete csocket; + break; + } + + if(!csocket->isConnected()) { + info.error("Child socket is not connected, quitting."); + delete csocket; + break; + } + + childpid = fork(); + + switch(childpid) { + case -1: // fork() returns -1 on failure + info.log("Fork error: %s", strerror(errno)); + exit(1); + case 0: // fork() returns 0 to the child process + delete socket; // Close listen socket. + newConnection(csocket, &info); + delete csocket; // Close communication socket. + exit(0); - switch(childpid) { - case -1: // fork() returns -1 on failure - info.log("Fork error: %s", strerror(errno)); - exit(1); - case 0: // fork() returns 0 to the child process - delete socket; // Close listen socket. - newConnection(csocket, &info); - delete csocket; // Close communication socket. - exit(0); - - default: // fork() returns new pid to the parent process - break; - } + default: // fork() returns new pid to the parent process + break; } } + delete socket; return 0; } |