#include <afsconfig.h>
#include <afs/param.h>
-
+#include <roken.h>
#include <sys/types.h>
#include <stdio.h>
#endif
#include <signal.h>
#include <sys/stat.h>
-#include "rx_clock.h"
-#include "rx.h"
-#include "rx_globals.h"
-#include "rx_null.h"
+#include <rx/rx_clock.h>
+#include <rx/rx.h>
+#include <rx/rx_globals.h>
+#include <rx/rx_null.h>
int error; /* Return this error number on a call */
int print = 0, eventlog = 0, rxlog = 0;
-extern rx_intentionallyDroppedPacketsPer100;
-extern char rxi_tracename[];
-extern int rx_initSendWindow, rx_initReceiveWindow;
-extern int rxi_nSendFrags, rxi_nRecvFrags;
-extern int (*rxi_syscallp) ();
struct clock computeTime, waitTime;
FILE *debugFile;
char *rcvFile;
int logstdout = 0;
+void Abort(char *msg, ...);
+void Quit(char *msg);
+void OpenFD(int n);
+int FileRequest(struct rx_call *call);
+int SimpleRequest(struct rx_call *call);
+
void
intSignal(int ignore)
{
rx_PrintStats(debugFile);
}
-int SimpleRequest(), FileRequest();
-
#if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV)
int
test_syscall(a3, a4, a5)
struct rx_securityClass *(secobjs[1]);
int err = 0;
int setFD = 0;
+ int jumbo = 0;
#if !defined(AFS_NT40_ENV) && !defined(AFS_LINUX20_ENV)
setlinebuf(stdout);
while (argc && **argv == '-') {
if (strcmp(*argv, "-verbose") == 0)
print = 1;
+ else if (strcmp(*argv, "-jumbo") == 0)
+ jumbo = 1;
else if (strcmp(*argv, "-rxlog") == 0)
rxlog = 1;
+#if defined(RXDEBUG) && !defined(AFS_NT40_ENV)
else if (strcmp(*argv, "-trace") == 0)
strcpy(rxi_tracename, *(++argv)), argc--;
+#endif
else if (strcmp(*argv, "-logstdout") == 0)
logstdout = 1;
else if (strcmp(*argv, "-eventlog") == 0)
rx_initReceiveWindow = atoi(*++argv), argc--;
else if (strcmp(*argv, "-file") == 0)
rcvFile = *++argv, argc--;
- else if (strcmp(*argv, "-drop") == 0)
+ else if (strcmp(*argv, "-drop") == 0) {
+#ifdef RXDEBUG
rx_intentionallyDroppedPacketsPer100 = atoi(*++argv), argc--;
+#else
+ fprintf(stderr, "ERROR: Compiled without RXDEBUG\n");
+#endif
+ }
else if (strcmp(*argv, "-err") == 0)
error = atoi(*++argv), argc--;
else if (strcmp(*argv, "-compute") == 0) {
if (setFD > 0)
OpenFD(setFD);
+
+#ifdef AFS_NT40_ENV
+ rx_EnableHotThread();
+#endif
+
+ if (!jumbo)
+ rx_SetNoJumbo();
+
+ rx_SetUdpBufSize(256 * 1024);
+
if (rx_Init(htons(2500)) != 0) {
printf("RX initialization failed, exiting.\n");
exit(1);
rcvFile ? FileRequest : SimpleRequest);
if (!service)
Abort("rx_NewService returned 0!\n");
+
+ rx_SetMinProcs(service, 2);
+ rx_SetMaxProcs(service, 100);
+ rx_SetCheckReach(service, 1);
+
printf("Using %d packet buffers\n", rx_nPackets);
rx_StartServer(1);
}
-SimpleRequest(call)
- struct rx_call *call;
+static char buf[2000000];
+
+int SimpleRequest(struct rx_call *call)
{
int n;
- int nbytes = 1000;
- char buf[1000];
+ int nbytes = sizeof(buf);
while ((n = rx_Read(call, buf, nbytes)) > 0)
if (print)
printf("stest: Received %d bytes\n", n);
if (!rx_Error(call)) {
/* Fake compute time (use select to lock out everything) */
- struct timeval t;
+#ifndef AFS_NT40_ENV
+ struct timeval t;
+#endif
if (!clock_IsZero(&computeTime)) {
- t.tv_sec = computeTime.sec;
- t.tv_usec = computeTime.usec;
#ifdef AFS_NT40_ENV
- Sleep(t.tv_sec);
+ Sleep(computeTime.sec * 1000 + 100 * computeTime.usec);
#else
+ t.tv_sec = computeTime.sec;
+ t.tv_usec = computeTime.usec;
+#ifdef AFS_PTHREAD_ENV
if (select(0, 0, 0, 0, &t) != 0)
Quit("Select didn't return 0");
+#else
+ IOMGR_Sleep(t.tv_sec);
+#endif
#endif
}
/* Then wait time (use iomgr_select to allow rx to run) */
if (!clock_IsZero(&waitTime)) {
+#ifdef AFS_NT40_ENV
+ Sleep(waitTime.sec * 1000 + 100 * waitTime.usec);
+#else
t.tv_sec = waitTime.sec;
t.tv_usec = waitTime.usec;
#ifdef AFS_PTHREAD_ENV
#else
IOMGR_Sleep(t.tv_sec);
#endif
+#endif
}
rx_Write(call, "So long, and thanks for all the fish!\n",
strlen("So long, and thanks for all the fish!\n"));
return 0;
}
-FileRequest(call)
- struct rx_call *call;
+int
+FileRequest(struct rx_call *call)
{
int fd;
struct stat status;
fd = open(rcvFile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
perror("open");
- return;
+ return -1;
}
fstat(fd, &status);
#ifdef AFS_NT40_ENV
return 0;
}
-Abort(msg, a, b, c, d, e)
+void
+Abort(char *msg, ...)
{
- printf((char *)msg, a, b, c, d, e);
+ va_list args;
+
+ va_start(args, msg);
+ printf((char *)msg, args);
+ va_end(args);
+
printf("\n");
if (debugFile) {
rx_PrintStats(debugFile);
fflush(debugFile);
}
- abort();
+ afs_abort();
+ exit(1);
}
-Quit(msg, a, b, c, d, e)
+void
+Quit(char *msg)
{
- printf((char *)msg, a, b, c, d, e);
- printf("\n");
+ printf("%s\n", msg);
if (debugFile) {
rx_PrintStats(debugFile);
fflush(debugFile);
* Open file descriptors until file descriptor n or higher is returned.
*/
#include <sys/stat.h>
-OpenFD(n)
- int n;
+void
+OpenFD(int n)
{
int i;
struct stat sbuf;