static bool_t xdrrx_putint32(XDR *axdrs, afs_int32 * lp) { afs_int32 code, l = htonl(*lp); XDR * xdrs = (XDR *)axdrs; struct rx_call *call = ((struct rx_call *)(xdrs)->x_private); #if defined(KERNEL) && defined(AFS_AIX32_ENV) char *saddr = (char *)&code; saddr -= STACK_TO_PIN; /* * Hack of hacks: Aix3.2 only guarantees that the next 2K of stack in pinned. Under * splnet (disables interrupts), which is set throughout rx, we can't swap in stack * pages if we need so we panic. Since sometimes, under splnet, we'll use more than * 2K stack we could try to bring the next few stack pages in here before we call the rx * layer. Of course this doesn't guarantee that those stack pages won't be swapped * out between here and calling splnet. So we now pin (and unpin) them instead to * guarantee that they remain there. */ if (pin(saddr, STACK_TO_PIN)) { saddr = NULL; rx_pin_failed++; } #endif code = (rx_Write32(call, &l) == sizeof(l)); #if defined(KERNEL) && defined(AFS_AIX32_ENV) if (saddr) unpin(saddr, STACK_TO_PIN); #endif return code; }
static bool_t xdrrx_putint64(XDR *axdrs, long *lp) { XDR * xdrs = (XDR *)axdrs; afs_int32 code, i = htonl(*lp); struct rx_call *call = ((struct rx_call *)(xdrs)->x_private); code = (rx_Write32(call, &i) == sizeof(i)); return code; }
static void * client_thread( void *vparams) { struct client_data *params = (struct client_data *)vparams; struct rx_call *call; afs_int32 data; int i, j; afs_uint32 *readwrite; int readp = FALSE; afs_uint32 size; afs_uint32 num; for (i = 0; i < params->times; i++) { DBFPRINT(("starting command ")); call = rx_NewCall(params->conn); if (call == NULL) errx(1, "rx_NewCall failed"); data = htonl(RX_PERF_VERSION); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send version (err %d)", rx_Error(call)); data = htonl(params->command); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); data = htonl(rxread_size); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send read size (err %d)", rx_Error(call)); data = htonl(rxwrite_size); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send write read (err %d)", rx_Error(call)); switch (params->command) { case RX_PERF_RECV: DBFPRINT(("command ")); data = htonl(params->bytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); DBFPRINT(("sending(%d) ", params->bytes)); if (do_readbytes(call, params->bytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_SEND: DBFPRINT(("command ")); data = htonl(params->bytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); DBFPRINT(("sending(%d) ", params->bytes)); if (do_sendbytes(call, params->bytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_RPC: DBFPRINT(("commands ")); data = htonl(params->sendbytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); data = htonl(params->readbytes); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send command (err %d)", rx_Error(call)); DBFPRINT(("send(%d) ", params->sendbytes)); if (do_sendbytes(call, params->sendbytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("recv(%d) ", params->readbytes)); if (do_readbytes(call, params->readbytes)) errx(1, "sendbytes (err %d)", rx_Error(call)); if (rx_Read32(call, &data) != 4) errx(1, "failed to read result from server (err %d)", rx_Error(call)); if (data != htonl(RXPERF_MAGIC_COOKIE)) warn("server send wrong magic cookie in responce"); DBFPRINT(("done\n")); break; case RX_PERF_FILE: readfile(params->filename, &readwrite, &num); data = htonl(num); if (rx_Write32(call, &data) != 4) errx(1, "rx_Write failed to send size (err %d)", rx_Error(call)); if (rx_Write(call, (char *)readwrite, num * sizeof(afs_uint32)) != num * sizeof(afs_uint32)) errx(1, "rx_Write failed to send list (err %d)", rx_Error(call)); for (j = 0; j < num; j++) { if (readwrite[j] == 0) readp = !readp; size = ntohl(readwrite[j]) * sizeof(afs_uint32); if (readp) { if (do_readbytes(call, size)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("read\n")); } else { if (do_sendbytes(call, size)) errx(1, "sendbytes (err %d)", rx_Error(call)); DBFPRINT(("send\n")); } } break; default: abort(); } rx_EndCall(call, 0); } #ifdef AFS_PTHREAD_ENV pthread_exit(NULL); #endif return NULL; }
static afs_int32 rxperf_ExecuteRequest(struct rx_call *call) { afs_int32 version; afs_int32 command; afs_int32 bytes; afs_int32 recvb; afs_int32 sendb; afs_int32 data; afs_uint32 num; afs_uint32 *readwrite; afs_uint32 i; int readp = TRUE; DBFPRINT(("got a request\n")); if (rx_Read32(call, &version) != 4) { warn("rx_Read failed to read version"); return -1; } if (htonl(RX_PERF_VERSION) != version) { warnx("client has wrong version"); return -1; } if (rx_Read32(call, &command) != 4) { warnx("rx_Read failed to read command"); return -1; } command = ntohl(command); if (rx_Read32(call, &data) != 4) { warnx("rx_Read failed to read size"); return -1; } rxread_size = ntohl(data); if (rxread_size > sizeof(somebuf)) { warnx("rxread_size too large %d", rxread_size); return -1; } if (rx_Read32(call, &data) != 4) { warnx("rx_Read failed to write size"); return -1; } rxwrite_size = ntohl(data); if (rxwrite_size > sizeof(somebuf)) { warnx("rxwrite_size too large %d", rxwrite_size); return -1; } switch (command) { case RX_PERF_SEND: DBFPRINT(("got a send request\n")); if (rx_Read32(call, &bytes) != 4) { warnx("rx_Read failed to read bytes"); return -1; } bytes = ntohl(bytes); DBFPRINT(("reading(%d) ", bytes)); do_readbytes(call, bytes); data = htonl(RXPERF_MAGIC_COOKIE); if (rx_Write32(call, &data) != 4) { warnx("rx_Write failed when sending back result"); return -1; } DBFPRINT(("done\n")); break; case RX_PERF_RPC: DBFPRINT(("got a rpc request, reading commands\n")); if (rx_Read32(call, &recvb) != 4) { warnx("rx_Read failed to read recvbytes"); return -1; } recvb = ntohl(recvb); if (rx_Read32(call, &sendb) != 4) { warnx("rx_Read failed to read sendbytes"); return -1; } sendb = ntohl(sendb); DBFPRINT(("read(%d) ", recvb)); if (do_readbytes(call, recvb)) { warnx("do_readbytes failed"); return -1; } DBFPRINT(("send(%d) ", sendb)); if (do_sendbytes(call, sendb)) { warnx("sendbytes failed"); return -1; } DBFPRINT(("done\n")); data = htonl(RXPERF_MAGIC_COOKIE); if (rx_Write32(call, &data) != 4) { warnx("rx_Write failed when sending back magic cookie"); return -1; } break; case RX_PERF_FILE: if (rx_Read32(call, &data) != 4) errx(1, "failed to read num from client"); num = ntohl(data); readwrite = malloc(num * sizeof(afs_uint32)); if (readwrite == NULL) err(1, "malloc"); if (rx_Read(call, (char*)readwrite, num * sizeof(afs_uint32)) != num * sizeof(afs_uint32)) errx(1, "failed to read recvlist from client"); for (i = 0; i < num; i++) { if (readwrite[i] == 0) { DBFPRINT(("readp %d", readwrite[i])); readp = !readp; } bytes = ntohl(readwrite[i]) * sizeof(afs_uint32); if (readp) { DBFPRINT(("read\n")); do_readbytes(call, bytes); } else { do_sendbytes(call, bytes); DBFPRINT(("send\n")); } } break; case RX_PERF_RECV: DBFPRINT(("got a recv request\n")); if (rx_Read32(call, &bytes) != 4) { warnx("rx_Read failed to read bytes"); return -1; } bytes = ntohl(bytes); DBFPRINT(("sending(%d) ", bytes)); do_sendbytes(call, bytes); data = htonl(RXPERF_MAGIC_COOKIE); if (rx_Write32(call, &data) != 4) { warnx("rx_Write failed when sending back result"); return -1; } DBFPRINT(("done\n")); break; default: warnx("client sent a unsupported command"); return -1; } DBFPRINT(("done with command\n")); return 0; }