diff --git a/.gitignore b/.gitignore index 6d5206b..c9f9e10 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,62 @@ modules.order Module.symvers Mkfile.old -dkms.conf \ No newline at end of file +dkms.conf + +# http://www.gnu.org/software/automake + +Makefile.in +/ar-lib +/mdate-sh +/py-compile +/test-driver +/ylwrap +.deps/ +.dirstamp + +# http://www.gnu.org/software/autoconf + +autom4te.cache +/autoscan.log +/autoscan-*.log +/aclocal.m4 +/compile +/config.cache +/config.guess +/config.h.in +/config.log +/config.status +/config.sub +/configure +/configure.scan +/depcomp +/install-sh +/missing +/stamp-h1 + +# https://www.gnu.org/software/libtool/ + +/ltmain.sh + +# http://www.gnu.org/software/texinfo + +/texinfo.tex + +# http://www.gnu.org/software/m4/ + +m4/libtool.m4 +m4/ltoptions.m4 +m4/ltsugar.m4 +m4/ltversion.m4 +m4/lt~obsolete.m4 + +# Generated Makefile +# (meta build system like autotools, +# can automatically generate from config.status script +# (which is called by configure script)) +Makefile + +SilverMUDServer +config.h +config.h.in +stamp-h1 \ No newline at end of file diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..983fa51 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ +bin_PROGRAMS = SilverMUDServer +dist_doc_DATA = README.org +SilverMUDServer_CFLAGS = -I/usr/include/guile/3.0 -I/usr -lguile-3.0 -lgc -lpthread -ldl -lgnutls + +SilverMUDServer_SOURCES = \ + source/server/connections.c \ + source/server/scheme-integration.c \ + source/server/main.c diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..8c0f855 --- /dev/null +++ b/configure.ac @@ -0,0 +1,8 @@ +AC_INIT([SilverMUD], [0.0.1], [barra@ocathain.ie]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) +AC_PROG_CC +AC_CONFIG_HEADERS([source/config.h]) +AC_CONFIG_FILES([ + Makefile +]) +AC_OUTPUT diff --git a/source/server/main.c b/source/server/main.c index 057a54b..dbbccc5 100644 --- a/source/server/main.c +++ b/source/server/main.c @@ -81,6 +81,8 @@ int main (int argc, char ** argv) fprintf(stderr, "Failed to create epoll instance. Aborting.\n"); exit(EXIT_FAILURE); } + + // Setup the epoll events we want to watch for: struct epoll_event watchedEvents; watchedEvents.events = EPOLLIN; watchedEvents.data.fd = masterSocket; @@ -132,12 +134,14 @@ int main (int argc, char ** argv) gnutls_transport_set_int(*tlsSession, newSocket); // Perform a TLS handshake: - volatile int handshakeReturnValue = 0; + int handshakeReturnValue = 0; do { handshakeReturnValue = gnutls_handshake(*tlsSession); } while (handshakeReturnValue < 0 && gnutls_error_is_fatal(handshakeReturnValue) == 0); + + // If the handshake was unsuccessful, close the connection: if (handshakeReturnValue < 0) { printf("%d", handshakeReturnValue); @@ -147,11 +151,10 @@ int main (int argc, char ** argv) close(newSocket); break; } - + + // Setup the epoll events we want to watch for: watchedEvents.events = EPOLLIN; - watchedEvents.data.fd = newSocket; - - // Add the completed file descriptor to the set: + watchedEvents.data.fd = newSocket; epoll_ctl(connectedClients, EPOLL_CTL_ADD, newSocket, &watchedEvents); // Add the connection to the list: