<div dir="ltr">Hello,<br><br>I'm implementing a server in MPI that accepts more than one connection from clients at the same time.<br>For do that I used MPI(mpich2-1.1.0a1.tar.gz) and pthreads.<br><br>What I want to do is a server that stays in a infinity loop waiting for connections (MPI_Comm_accept(portMD, MPI_INFO_NULL, 0, MPI_COMM_WORLD, newCommClient);). When a connection is established, he creates a new thread and return to wait more connections. That means, the server and the thread will work in parallel.<br>
<br>The function that the thread will execute calls mpi functions, like MPI_probe, MPI_Get_count, MPI_Recv, MPI_Send, MPI_Pack and MPI_Unpack.<br><br>The problem I'm having is that the server and the thread are not working in parallel successfully. Sometimes, the program hangs, do nothing, and in another times a fatal error appears (Assertion failed in file sock_wait.i at line 236: (pollfd->events & (0x001 | 0x004)) || pollfd->fd == -1).<br>
<br>When I put the server to sleep for a moment, before he will wait another connection, during the time he was sleeping the created thread works fine. Once the server wakes up and starts to wait for a connection, things stop working.<br>
<br>A peace of my code (Server):<br>-----------------------------------------------------------------------------------------------------------------------------<br>// arguments passed to a thread<br>typedef struct<br>{ MPI_Comm communicator;<br>
char * path1;<br> char * path2;<br> char * port; <br>} ThreadParam;<br><br> pthread_t threads[10];<br> int t =0;<br> int rc;<br><br><br> ThreadParam * listParam = NULL;<br> MPI_Comm * newCommClient;<br> <br><br> /* server infinity loop */<br>
while (time_out > 10)<br> {<br> <br> newCommClient = malloc(sizeof(MPI_Comm));<br> <br> <br> /* waiting for a connection */<br> MPI_Comm_accept(portMD, MPI_INFO_NULL, 0, MPI_COMM_WORLD, newCommClient);<br>
<br> listParam = malloc(sizeof(ThreadParam)); <br> listParam->communicator = *newCommClient; //with this communicator the thread will talk with the / //client <br>
listParam->path1 = argv[2];<br> listParam->path2 = argv[4];<br> listParam->port = portMD;<br> <br> rc = pthread_create(&threads[t], NULL, threadfunc, (void *) listParam);<br> <br> if (rc){<br>
printf("ERROR; return code from pthread_create() is %d\n", rc);<br> exit(-1);<br> }<br> //sleep(1); <br> t++;<br> }<br><br>-----------------------------------------------------------------------------------------------------------------------------<br>
Please, I need help to solve this problem!!<br><br>Thanks very mych!<br><br>Gisele<br></div>