diff --git a/install-dependencies.sh b/install-dependencies.sh index 4ffe35d..18e9adc 100644 --- a/install-dependencies.sh +++ b/install-dependencies.sh @@ -4,6 +4,11 @@ # Run this script to install the required Jansson and JWT packages. # BASE=`pwd` +# +# Running this script multiple times will wipe the existing build +# and reclone both repositories +/bin/rm -rf ${BASE}/deps jansson libjwt +# test -d ${BASE}/deps || mkdir ${BASE}/deps git clone https://github.com/akheron/jansson.git (cd jansson; diff --git a/src/Makefile b/src/Makefile index 1a61164..49c73f8 100644 --- a/src/Makefile +++ b/src/Makefile @@ -22,4 +22,4 @@ server: $(OBJ) $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) clean: - /bin/rm $(OBJ) $(OTHERS) + /bin/rm -f $(OBJ) $(OTHERS) server diff --git a/src/bufio.h b/src/bufio.h index 3e3c67c..3b21ef3 100644 --- a/src/bufio.h +++ b/src/bufio.h @@ -3,7 +3,8 @@ #include "buffer.h" -struct bufio; +struct bufio; // opaque type + // users should interact only via the public functions below struct bufio * bufio_create(int socket); void bufio_close(struct bufio * self); void bufio_truncate(struct bufio * self); diff --git a/src/main.c b/src/main.c index fe51d23..bf43535 100644 --- a/src/main.c +++ b/src/main.c @@ -74,6 +74,7 @@ main(int ac, char *av[]) case 'e': token_expiration_time = atoi(optarg); + fprintf(stderr, "token expiration time is %d\n", token_expiration_time); break; case 's': diff --git a/src/socket.c b/src/socket.c index ec3aea3..36775df 100644 --- a/src/socket.c +++ b/src/socket.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -127,6 +128,15 @@ socket_accept_client(int accepting_socket) return -1; } + /* Performance tuning. Turn off Nagle's algorithm. + * Otherwise, when the servers sends a reply to the client, and the reply + * is small relative to the MSS size, there would be a delay of 40ms + * during which the OS would hope in vain for more data to be sent. + * See tcp(7) + */ + int i = 1; + setsockopt(client, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i)); + /* The following will help with debugging your server. * Adjust and/or remove as you see fit. */