Lines Matching refs:shared
101 static PRIntervalTime Timeout(const Shared *shared)
103 PRIntervalTime timeout = shared->timeout;
104 if (shared->random)
113 static void CauseTimeout(const Shared *shared)
115 if (shared->intermittant) PR_Sleep(Timeout(shared));
118 static PRStatus MakeReceiver(Shared *shared)
121 if (PR_IsNetAddrType(&shared->serverAddress, PR_IpAddrLoopback))
131 if (shared->debug > 0)
137 if (shared->debug > 1)
143 if (shared->debug > 1)
145 if (shared->debug > 1)
151 shared->failed = PR_TRUE;
152 if (shared->debug > 0)
163 Shared *shared = (Shared*)arg;
166 debug_out = (0 == shared->debug) ? NULL : PR_GetSpecialFD(PR_StandardError);
168 buffer = (char*)PR_MALLOC(shared->message_length);
170 for (bytes = 0; bytes < shared->message_length; ++bytes)
174 for (bytes = 0; bytes < shared->message_length; ++bytes)
183 for (loop = 0; loop < shared->messages; ++loop)
185 if (shared->debug > 1)
197 PR_Sleep(shared->dally);
198 if (shared->debug > 1)
201 PR_NetAddrToString(&shared->serverAddress, buf, sizeof(buf));
205 clientSock, &shared->serverAddress, Timeout(shared));
208 PRInt32 descriptor_length = (loop < (shared->messages - 1)) ?
209 shared->message_length : 0;
211 if (shared->debug > 1)
214 CauseTimeout(shared); /* might cause server to timeout */
217 flags, Timeout(shared));
220 shared->failed = PR_TRUE;
221 if (shared->debug > 0)
226 CauseTimeout(shared);
229 flags, Timeout(shared));
232 shared->failed = PR_TRUE;
233 if (shared->debug > 0)
237 if (shared->debug > 1) PR_fprintf(debug_out, "closing ... ");
240 if (shared->debug > 1)
248 if (shared->debug > 1) PL_FPrintError(debug_out, "connect failed");
252 if (MakeReceiver(shared) == PR_FAILURE) break;
256 if (shared->debug > 1) PR_fprintf(debug_out, " exiting\n");
263 shared->failed = PR_TRUE;
264 if (shared->debug > 0) PL_FPrintError(debug_out, "create socket");
292 Shared *shared = NULL;
299 shared = PR_NEWZAP(Shared);
301 shared->debug = 0;
302 shared->failed = PR_FALSE;
303 shared->random = PR_FALSE;
304 shared->messages = DEFAULT_MESSAGES;
305 shared->message_length = DEFAULT_MESSAGESIZE;
308 memset(&shared->serverAddress, 0, sizeof(shared->serverAddress));
309 rv = PR_InitializeNetAddr(PR_IpAddrLoopback, BASE_PORT, &shared->serverAddress);
318 if (0 == shared->debug) shared->debug = 1;
321 if (0 == shared->debug) shared->debug = 2;
324 shared->intermittant = PR_TRUE;
327 shared->random = PR_TRUE;
340 es, &host, BASE_PORT, &shared->serverAddress);
345 shared->messages = atoi(opt->value);
357 shared->message_length = atoi(opt->value);
367 if (0 == shared->messages) shared->messages = DEFAULT_MESSAGES;
368 if (0 == shared->message_length) shared->message_length = DEFAULT_MESSAGESIZE;
370 shared->dally = PR_SecondsToInterval(dally);
371 shared->timeout = PR_SecondsToInterval(timeout);
377 PR_USER_THREAD, Connect, shared,
387 ((shared->failed) ? "FAILED" : "PASSED"));
388 exitStatus = (shared->failed) ? 1 : 0;
389 PR_DELETE(shared);