working -R
This commit is contained in:
18
src/server.c
18
src/server.c
@ -67,13 +67,16 @@ int main(int argc, char *argv[]) {
|
||||
int maxBacklog; CONFGETINT(maxBacklog, config, "socket", "backlog", NULL, 10);
|
||||
ini_free(config);
|
||||
|
||||
queueT *queue = NULL;
|
||||
taglia_t *taglia = NULL;
|
||||
|
||||
sigset_t mask;
|
||||
sigfillset(&mask);
|
||||
sigdelset(&mask, SIGPIPE); // tolgo soltanto la sigpipe
|
||||
|
||||
if (pthread_sigmask(SIG_SETMASK, &mask, NULL) != 0) {
|
||||
fprintf(stderr, "ERROR setting mask\n");
|
||||
goto _cleanup;
|
||||
goto _cleanup_beforesigthread;
|
||||
}
|
||||
|
||||
// ignoro SIGPIPE per evitare di essere terminato da una scrittura su un socket
|
||||
@ -82,18 +85,18 @@ int main(int argc, char *argv[]) {
|
||||
s.sa_handler = SIG_IGN;
|
||||
if ( (sigaction(SIGPIPE,&s,NULL)) == -1 ) {
|
||||
perror("sigaction");
|
||||
goto _cleanup;
|
||||
goto _cleanup_beforesigthread;
|
||||
}
|
||||
|
||||
// remove("mysock"); maybe necessary???
|
||||
|
||||
|
||||
// creo la struttura per il log
|
||||
taglia_t *taglia = taglia_init(logFile, 0);
|
||||
taglia = taglia_init(logFile, 0);
|
||||
free(logFile); // free del nome del file
|
||||
if(taglia==NULL) {
|
||||
perror("taglia_init");
|
||||
goto _cleanup;
|
||||
goto _cleanup_beforesigthread;
|
||||
}
|
||||
// risorse per il logfile usate nel main
|
||||
char buf[2048];
|
||||
@ -109,7 +112,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
if (pipe(request_pipe) == -1) {
|
||||
perror("pipe");
|
||||
goto _cleanup;
|
||||
goto _cleanup_beforesigthread;
|
||||
}
|
||||
|
||||
|
||||
@ -171,7 +174,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
// creo la queue
|
||||
queueT *queue = createQueue(maxFiles, maxSize);
|
||||
queue = createQueue(maxFiles, maxSize);
|
||||
|
||||
// creo la lista dei client in attesa a una lock
|
||||
waiting_t *waiting = NULL;
|
||||
@ -437,6 +440,9 @@ int main(int argc, char *argv[]) {
|
||||
return 0;
|
||||
|
||||
_cleanup:
|
||||
pthread_cancel(sighandler_thread);
|
||||
pthread_join(sighandler_thread, NULL);
|
||||
_cleanup_beforesigthread:
|
||||
if(queue) {
|
||||
destroyQueue(queue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user