Commit 083f135f authored by Mike Hibler's avatar Mike Hibler
Browse files

Add debug (-d) and set socket size (-k) options.

parent e0633f56
......@@ -76,7 +76,7 @@ main(int argc, char **argv)
FrisLog("%s: listening as %d/%d on port %d for image data from %s (max of %llu bytes)",
path, geteuid(), getegid(), portnum, inet_ntoa(clientip), maxsize);
if (idletimeout || timeout)
FrisLog("%s: using idletimeout=%ds, timeout=%ds\n",
FrisLog("%s: using idletimeout=%ds, timeout=%ds",
path, idletimeout, timeout);
rv = recv_file();
......@@ -88,8 +88,9 @@ main(int argc, char **argv)
static void
parse_args(int argc, char **argv)
{
int ch;
while ((ch = getopt(argc, argv, "m:p:i:b:I:T:s:A:d")) != -1) {
int ch, mem;
while ((ch = getopt(argc, argv, "m:p:i:b:I:T:s:A:dk:")) != -1) {
switch (ch) {
case 'd':
debug++;
......@@ -101,6 +102,13 @@ parse_args(int argc, char **argv)
exit(1);
}
break;
case 'k':
mem = atoi(optarg);
if (mem <= 0 || (mem * 1024) > MAXSOCKBUFSIZE)
sockbufsize = MAXSOCKBUFSIZE;
else
sockbufsize = mem * 1024;
break;
case 'p':
if (strchr(optarg, '-')) {
char *h = strchr(optarg, '-');
......@@ -184,7 +192,7 @@ static void
usage(void)
{
char *usagestr =
"\nusage: frisuploader [-i iface] [-T timo] [-s maxsize] -m IP -p port outfile\n"
"\nusage: frisuploader [-i iface] [-T timo] [-k size] [-s maxsize] -m IP -p port outfile\n"
"Upload a file from client identified by <IP>:<port> and save to <outfile>.\n"
"Options:\n"
"<outfile> File to save the uploaded data into.\n"
......@@ -195,6 +203,7 @@ usage(void)
" -i <iface> Interface on which to listen (specified by local IP).\n"
" -I <timo> Max time (in seconds) to allow connect to be idle (no traffic from client).\n"
" -T <timo> Max time (in seconds) to wait for upload to complete.\n"
" -k <size> Specify the socket buffer size to use (1M by default)\n"
" -s <size> Maximum amount of data (in bytes) to upload.\n"
"\n\n";
......
......@@ -84,8 +84,8 @@ main(int argc, char **argv)
int timo = 5; /* XXX */
int rv;
ClientLogInit();
parse_args(argc, argv);
ClientLogInit();
/* Special case: streaming from stdin */
if (strcmp(uploadpath, "-") == 0) {
......@@ -329,9 +329,20 @@ main(int argc, char **argv)
static void
parse_args(int argc, char **argv)
{
int ch;
while ((ch = getopt(argc, argv, "S:p:F:Q:sb:I:T:NP:o")) != -1) {
int ch, mem;
while ((ch = getopt(argc, argv, "S:p:F:Q:sb:I:T:NP:odk:")) != -1) {
switch (ch) {
case 'd':
debug++;
break;
case 'k':
mem = atoi(optarg);
if (mem <= 0 || (mem * 1024) > MAXSOCKBUFSIZE)
sockbufsize = MAXSOCKBUFSIZE;
else
sockbufsize = mem * 1024;
break;
case 'S':
mshost = optarg;
break;
......@@ -419,7 +430,8 @@ usage(void)
"Options:\n"
" -S <IP> Specify the IP address of the master server.\n"
" -p <port> Specify the port number of the master server.\n"
" -b <bufsize> Specify the IO buffer size to use (64K by default)\n"
" -b <size> Specify the IO buffer size to use (64K by default)\n"
" -k <size> Specify the socket buffer size to use (1M by default)\n"
" -T <timeout> Time in seconds to wait for the upload to finish.\n"
" -Q <fileid> Use in place of -F to just ask the server about\n"
" the indicated file (image). Tells whether the\n"
......@@ -433,7 +445,8 @@ usage(void)
"the actual upload daemon rather than the master server.\n"
"That daemon must be started manually in advance.\n"
"Options:\n"
" -b <bufsize> Specify the IO buffer size to use (64K by default)\n"
" -b <size> Specify the IO buffer size to use (64K by default)\n"
" -k <size> Specify the socket buffer size to use (1M by default)\n"
" -T <timeout> Time in seconds to wait for the upload to finish.\n"
" -s Use encryption.\n\n"
#endif
......
/*
* Copyright (c) 2010-2014 University of Utah and the Flux Group.
* Copyright (c) 2010-2015 University of Utah and the Flux Group.
*
* {{{EMULAB-LICENSE
*
......@@ -56,7 +56,7 @@ conn *
conn_accept_tcp(int sock, struct in_addr *client, int conntimo, int iotimo)
{
conn *newconn;
int nsock;
int nsock, sz;
struct sockaddr_in sin;
socklen_t len;
......@@ -116,6 +116,10 @@ conn_accept_tcp(int sock, struct in_addr *client, int conntimo, int iotimo)
}
}
sz = sockbufsize;
if (setsockopt(nsock, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz)) < 0)
FrisPwarning("Could not set send socket buffer size to %d", sz);
newconn->ctype = CONN_SOCKET;
newconn->flags = 0;
newconn->desc.sockfd = nsock;
......@@ -127,6 +131,7 @@ conn *
conn_open(in_addr_t addr, in_port_t port, int usessl, int conntimo, int iotimo)
{
conn *newconn = malloc(sizeof *newconn);
int sz;
if (newconn == NULL) {
FrisLog("Out of memory");
......@@ -229,6 +234,10 @@ conn_open(in_addr_t addr, in_port_t port, int usessl, int conntimo, int iotimo)
}
}
sz = sockbufsize;
if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &sz, sizeof(sz)) < 0)
FrisPwarning("Could not set send socket buffer size to %d", sz);
newconn->ctype = CONN_SOCKET;
newconn->flags = 0;
newconn->desc.sockfd = sock;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment