Lines Matching refs:shared

71 static PRIntervalTime Timeout(const Shared *shared)
73 PRIntervalTime timeout = shared->timeout;
74 if (shared->random)
90 Shared *shared = (Shared*)arg;
99 if (NULL != shared->debug)
100 PR_fprintf(shared->debug, "[%d]accepting ... ", loop++);
102 shared->listenSock, &clientAddr, Timeout(shared));
105 if (NULL != shared->debug)
106 PR_fprintf(shared->debug, "reading length ... ");
109 flags, Timeout(shared));
115 if (NULL != shared->debug)
116 PR_fprintf(shared->debug, "%d bytes ... ", descriptor.length);
128 toread, flags, Timeout(shared));
131 if (NULL != shared->debug)
132 PR_fprintf(shared->debug, "read data failed...");
137 else if (NULL != shared->debug)
139 PR_fprintf(shared->debug, "read desciptor failed...");
142 if (NULL != shared->debug)
143 PR_fprintf(shared->debug, "closing");
145 if ((PR_FAILURE == rv) && (NULL != shared->debug))
147 PR_fprintf(shared->debug, " failed");
148 shared->passed = PR_FALSE;
151 if (PR_FAILURE == rv) if (NULL != shared->debug)
153 PR_fprintf(shared->debug, " failed");
154 shared->passed = PR_FALSE;
165 if ((descriptor.checksum != checksum) && (NULL != shared->debug))
167 PR_fprintf(shared->debug, " ... data mismatch");
168 shared->passed = PR_FALSE;
173 PR_Lock(shared->ml);
174 shared->status = stopped;
175 PR_NotifyCondVar(shared->cv);
176 PR_Unlock(shared->ml);
178 if (NULL != shared->debug)
179 PR_fprintf(shared->debug, "\n");
185 if (NULL != shared->debug) PL_PrintError("Accept");
186 shared->passed = PR_FALSE;
189 } while (running == shared->status);
198 Shared *shared;
210 shared = PR_NEWZAP(Shared);
212 shared->debug = NULL;
213 shared->passed = PR_TRUE;
214 shared->random = PR_TRUE;
215 shared->status = running;
216 shared->ml = PR_NewLock();
217 shared->cv = PR_NewCondVar(shared->ml);
225 shared->debug = PR_GetSpecialFD(PR_StandardError);
240 shared->random = PR_TRUE;
256 shared->timeout = PR_SecondsToInterval(timeout);
259 shared->listenSock = PR_NewTCPSocket();
260 if (shared->listenSock)
264 rv = PR_SetSocketOption(shared->listenSock, &sockOpt);
266 rv = PR_Bind(shared->listenSock, &listenAddr);
269 rv = PR_Listen(shared->listenSock, threads + backlog);
276 PR_USER_THREAD, Accept, shared,
282 PR_Lock(shared->ml);
283 while (shared->status == running)
284 PR_WaitCondVar(shared->cv, PR_INTERVAL_NO_TIMEOUT);
285 PR_Unlock(shared->ml);
297 if (shared->debug) PL_PrintError("Listen");
298 shared->passed = PR_FALSE;
303 if (shared->debug) PL_PrintError("Bind");
304 shared->passed = PR_FALSE;
307 PR_Close(shared->listenSock);
311 if (shared->debug) PL_PrintError("Create");
312 shared->passed = PR_FALSE;
315 PR_DestroyCondVar(shared->cv);
316 PR_DestroyLock(shared->ml);
320 ((shared->passed) ? "PASSED" : "FAILED"));
322 exitStatus = (shared->passed) ? 0 : 1;
323 PR_DELETE(shared);