#include <signal.h>#include <pthread.h>#include "common.h"#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <errno.h>#include <string.h>#include "com_defs.h"#include "common.h"#include "fat_defs.h"#include "fat.h"Vai al codice sorgente di questo file.
Funzioni | |
| void * | thread_servernte (void *) |
This program is free software; you can redistribuite it and/or modify it under the terms of the GNU/General Pubblic License as published the Free software Foundation; either version 2 of the License, or (at your opinion) any later version.
Definizione nel file comandi.h.
| void* thread_servernte | ( | void * | ) |
Thread delegato all'esecuzione dei messaggi mandati dai client
Definizione alla linea 126 del file comandi.c.
00126 { 00127 extern struct lista my_socket; 00128 extern pthread_mutex_t lock; 00129 extern pthread_cond_t wait_me; 00130 extern int num_threads; 00131 sigset_t set; 00132 channel_t sk_cl; 00133 message_t msg; 00134 int recive_val=0; 00135 00136 sk_cl = *(int *)sk; 00137 msg.buffer = NULL; 00138 00139 /* Blocco i segnali */ 00140 if (sigfillset(&set) == -1){ 00141 errore(__FILE__,__LINE__,"Server: error sigfillset",errno); 00142 return 0; 00143 } 00144 if (pthread_sigmask(SIG_SETMASK, &set, NULL) != 0) { 00145 errore(__FILE__,__LINE__,"Server: pthread_sigmask error 'sigsetmask'",errno); 00146 return 0; 00147 } 00148 00149 while (recive_val!=SEOF){ 00150 if ((recive_val = receiveMessage(sk_cl, &msg)) == -1) break; 00151 else if (recive_val != SEOF){ /* !SIGPIPE */ 00152 switch(msg.type){ 00153 case MSG_MKDIR: 00154 msg_mkdir(&msg); 00155 break; 00156 case MSG_LS: 00157 msg_ls(&msg); 00158 break; 00159 case MSG_MKFILE: 00160 msg_mkfile(&msg); 00161 break; 00162 case MSG_FREAD: 00163 msg_fread(&msg); 00164 break; 00165 case MSG_FWRITE: 00166 msg_fwrite(&msg); 00167 break; 00168 } 00169 if (sendMessage(sk_cl, &msg) == -1) break; 00170 } 00171 } 00172 /* Chiudo il socket di comunicazione tra client e server */ 00173 closeSocket(sk_cl); 00174 /* Rimuovo il thread dalla lista dei thread */ 00175 pthread_mutex_lock(&lock); 00176 num_threads--; 00177 rimuovi(sk_cl, &my_socket); 00178 pthread_mutex_unlock(&lock); 00179 pthread_cond_signal(&wait_me); 00180 00181 return 0; 00182 }
1.6.3