last bug fixes and test2 & test3
This commit is contained in:
@ -323,7 +323,7 @@ int reorderCommandList(cmd_t **l) {
|
||||
prev->arg = t.arg;
|
||||
prev->name = t.name;
|
||||
|
||||
if(!prev->next)
|
||||
if(!tmp->next)
|
||||
break;
|
||||
|
||||
// add redirect to dev/null for next command if it's r or R
|
||||
|
||||
20
src/server.c
20
src/server.c
@ -19,12 +19,7 @@
|
||||
#include <taglialegna.h>
|
||||
|
||||
|
||||
/**
|
||||
* @struct sigHandlerArgs_t
|
||||
* @brief struttura contenente le informazioni da passare
|
||||
* al signal handler thread
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
sigset_t *set; // set dei segnali da gestire (mascherati)
|
||||
int signal_pipe; // descrittore di scrittura di una pipe senza nome
|
||||
@ -34,7 +29,6 @@ typedef struct {
|
||||
static void *sigHandler(void *arg);
|
||||
|
||||
static void usage(const char *argv0) {
|
||||
// TODO change this
|
||||
fprintf(stderr, "use: %s <config file location>\n", argv0);
|
||||
}
|
||||
|
||||
@ -266,7 +260,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
// scrivo sul log
|
||||
n = snprintf(buf, sizeof(buf), "New client: %ld\n", *connfd);
|
||||
n = snprintf(buf, sizeof(buf), "Nuovo client: %ld\n", *connfd);
|
||||
if( n<0 ) {
|
||||
perror("snprintf");
|
||||
free(connfd);
|
||||
@ -318,16 +312,6 @@ int main(int argc, char *argv[]) {
|
||||
switch (pdr) {
|
||||
case -1: // client disconnected
|
||||
--numberOfConnections;
|
||||
n = snprintf(buf, sizeof(buf), "Client %ld disconnected.\n", pdr);
|
||||
if( n<0 ) {
|
||||
perror("snprintf");
|
||||
free(connfd);
|
||||
goto _cleanup;
|
||||
}
|
||||
if( taglia_log(taglia, buf) < 0) {
|
||||
free(connfd);
|
||||
goto _cleanup;
|
||||
}
|
||||
if (stopNewConnections && numberOfConnections <= 0) {
|
||||
quit = 1;
|
||||
// termino il signalThread
|
||||
|
||||
@ -27,15 +27,26 @@ void threadF(void *arg) {
|
||||
}
|
||||
|
||||
threadT *argl = (threadT *) arg;
|
||||
|
||||
long connfd = argl->connfd;
|
||||
volatile int *quit = argl->quit;
|
||||
int request_pipe = argl->request_pipe;
|
||||
queueT *q = argl->q;
|
||||
taglia_t *taglia = argl->taglia;
|
||||
// threadpool_t *pool = argl->pool;
|
||||
threadpool_t *pool = argl->pool;
|
||||
pthread_mutex_t *lock = argl->lock;
|
||||
waiting_t **waiting = argl->waiting;
|
||||
|
||||
int myid = -1;
|
||||
pthread_t tid = pthread_self();
|
||||
|
||||
for (int i = 0; i < pool->numthreads ; ++i) {
|
||||
if(pthread_equal(pool->threads[i], tid)) {
|
||||
myid = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fd_set set, tmpset;
|
||||
FD_ZERO(&set);
|
||||
FD_SET(connfd, &set);
|
||||
@ -121,7 +132,7 @@ closeConnection:
|
||||
// log
|
||||
int m = 0;
|
||||
char buf[1024];
|
||||
m = snprintf(buf, sizeof(buf), "Servito una richiesta del client %ld.\n", connfd);
|
||||
m = snprintf(buf, sizeof(buf), "Thread %d ha servito una richiesta del client %ld.\n", myid, connfd);
|
||||
if( m<0 ) {
|
||||
perror("snprintf");
|
||||
goto _cleanup;
|
||||
|
||||
Reference in New Issue
Block a user