# HG changeset patch # User Nathan Phillip Brink # Date 2010-07-22 00:03:45 # Node ID 92659c5651efd26d49106f365adbd7fc7b999573 # Parent 27eb6c6418f666fe243df1e40aace06a4801d06e Reformed buildsystem. - replace malloc.h with stdlib.h - use AC_CONFIG_HEADERS for cleaner compile output - clean out some useless AC_* macros and add useful AC_TYPE_UINT* macros diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -17,33 +17,28 @@ AC_PREREQ(2.61) AC_INIT([distren],[0.0],[http://bugs.ohnopub.net/], [], [http://ohnopub.net/distren/]) +AC_CONFIG_HEADERS([src/common/config.h]) AC_CONFIG_SRCDIR([src/server/distrend.c]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CC AC_PROG_LIBTOOL -#AC_PROG_RANLIB #don't add this even if autoscan says to, because AC_PROG_LIBTOOL is enough AM_INIT_AUTOMAKE([gnu dist-bzip2 subdir-objects -Wall]) AM_PROG_CC_C_O -#basic low-level checks (suggested by autoscan) -AC_CHECK_FUNCS([dup2]) -AC_CHECK_FUNCS([memset]) -AC_CHECK_FUNCS([strdup]) - -AC_CHECK_HEADERS([fcntl.h]) -AC_CHECK_HEADERS([malloc.h]) - -AC_FUNC_FORK -AC_FUNC_MALLOC - +dnl these macros force the refered to types to be available without me +dnl writing my own magic :-) AC_TYPE_PID_T AC_TYPE_SIZE_T -# selective compilation -# For now, this is only left for when the C-based client is -# reintroducded. +AC_TYPE_UINT8_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T + +dnl selective compilation +dnl For now, this is only left for when the C-based client is +dnl reintroducded. AC_ARG_ENABLE([server], [AS_HELP_STRING([--disable-server],[Don't build the distren server])], [enable_server=$enableval], @@ -51,30 +46,24 @@ AC_ARG_ENABLE([server], AM_CONDITIONAL([ENABLE_SERVER], [test "x$enable_server" = "xyes"]) -# to grab GNU-specific function prototypes for the following functions: -# getline -AC_DEFINE([_GNU_SOURCE], [1]) +dnl package dependencies: -#package dependencies: - -PKG_PROG_PKG_CONFIG(0.17.2) - - -PKGCONFIG_OHNOWRAP([DISTLIBS], [libconfuse >= 2.5 libcurl libxml-2.0 liblist >= 2.2.1 libarchive >= 2.8.0 ]) +PKG_CHECK_MODULES([DISTLIBS], [libconfuse >= 2.5 libcurl libxml-2.0 liblist >= 2.3.1 libarchive >= 2.8.0]) AX_LIB_MYSQL AS_IF( [test "x${MYSQL_VERSION}" = "x"], [ AC_MSG_ERROR([I need mysql]) ] ) -PKGCONFIG_OHNOWRAP([CHECK], [check >= 0.9.3]) +PKG_CHECK_MODULES([CHECK], [check >= 0.9.3]) -# define paths for configuration files: +dnl define paths for configuration files until a better arrangement is +dnl made: AC_DEFINE_DIR([LOCALSTATEDIR], [localstatedir], [Default directory for storing state information]) AC_DEFINE_DIR([RUNSTATEDIR], [localstatedir/run], [Default directory for registering runtime information like pid-files]) AC_CONFIG_FILES([Makefile -etc/distrendaemon.conf -etc/distrenslave.conf + etc/distrendaemon.conf + etc/distrenslave.conf ]) AC_OUTPUT diff --git a/m4/pkgconfig_ohnowrap.m4 b/m4/pkgconfig_ohnowrap.m4 deleted file mode 100644 --- a/m4/pkgconfig_ohnowrap.m4 +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2009 Nathan Phillip Brink -# -# This file is a part of DistRen. -# -# Distren is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# DistRen is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with DistRen. If not, see . -# - -# PKGCONFIG_OHNOWRAP(VARIABLE-PREFIX, MODULES) -# see bug 13912 on freedesktop's bugzilla -# $1 is the var to store stuff in -# $2 is the listing of modules to pass to PKG_CHECK_MODULES -# -# Original code derived from and depending on pkg.m4 distributed with dev-util/pkgconfig-0.23 -# which is Copyright (c) 2004 Scott James Remnant -# -AC_DEFUN([PKGCONFIG_OHNOWRAP], -[dnl -AC_ARG_VAR([$1][_LDADD],[Linker names of libraries to link to for $1])dnl -AC_ARG_VAR([$1][_LDFLAGS],[Linker flags for linking to libraries for $1])dnl - -PKG_CHECK_MODULES([$1], [$2]) - -_PKG_CONFIG([$1][_LDADD], [libs-only-l], [$2]) -_PKG_CONFIG([$1][_LDFLAGS], [libs-only-other], [$2]) - -$1[]_LDADD=$pkg_cv_[]$1[]_LDADD -$1[]_LDFLAGS=$pkg_cv_[]$1[]_LDFLAGS -]) diff --git a/src/client/distren.c b/src/client/distren.c --- a/src/client/distren.c +++ b/src/client/distren.c @@ -29,6 +29,8 @@ */ +#include "common/config.h" + #include "distren.h" #include /* sprintf, printf */ @@ -37,7 +39,6 @@ #include #include // for strcat - int main(int argc, char *argv[]) { int doLogin = 0; diff --git a/src/client/libdistren.c b/src/client/libdistren.c --- a/src/client/libdistren.c +++ b/src/client/libdistren.c @@ -21,10 +21,12 @@ Implementation of distren_* functions from distren.h excluding distren_job_* functions. */ +#include "common/config.h" + #include "libdistren.h" -#include #include +#include /** @todo needs to read configuration in diff --git a/src/client/libdistren_config.c b/src/client/libdistren_config.c --- a/src/client/libdistren_config.c +++ b/src/client/libdistren_config.c @@ -21,6 +21,8 @@ Functions and code for retrieving the client's configuration information. */ +#include "common/config.h" + #include "client/libdistren.h" #include "common/options.h" diff --git a/src/client/libdistren_job.c b/src/client/libdistren_job.c --- a/src/client/libdistren_job.c +++ b/src/client/libdistren_job.c @@ -21,6 +21,8 @@ Implementation of distren_job_* functions from distren.h. */ +#include "common/config.h" + #include "libdistren.h" /** diff --git a/src/client/libdistren_unbias.c b/src/client/libdistren_unbias.c --- a/src/client/libdistren_unbias.c +++ b/src/client/libdistren_unbias.c @@ -21,6 +21,8 @@ Implementation of libdistren functions that exist to prevent this library from being biased toward certain methods of reporting errors/debug info or free()ing and malloc()ing */ +#include "common/config.h" + #include "libdistren.h" void *_malloc(distren_t distren, size_t size) diff --git a/src/common/asprintf.c b/src/common/asprintf.c --- a/src/common/asprintf.c +++ b/src/common/asprintf.c @@ -17,6 +17,8 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include #include #include diff --git a/src/common/execio.c b/src/common/execio.c --- a/src/common/execio.c +++ b/src/common/execio.c @@ -17,7 +17,9 @@ along with DistRen. If not, see . */ -#include "execio.h" +#include "common/config.h" + +#include "common/execio.h" #include #include @@ -25,7 +27,6 @@ #include #endif #include -#include #include #include #include diff --git a/src/common/misc.c b/src/common/misc.c --- a/src/common/misc.c +++ b/src/common/misc.c @@ -17,12 +17,14 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "common/misc.h" #include -#include #include #include +#include char *distren_getcwd() { diff --git a/src/common/multiio.c b/src/common/multiio.c --- a/src/common/multiio.c +++ b/src/common/multiio.c @@ -18,13 +18,15 @@ */ +#include "common/config.h" + #include "common/multiio.h" #include #include -#include #include #include +#include #include struct multiio_socket_info diff --git a/src/common/options.c b/src/common/options.c --- a/src/common/options.c +++ b/src/common/options.c @@ -17,6 +17,8 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "common/options.h" #include "common/asprintf.h" diff --git a/src/common/protocol.c b/src/common/protocol.c --- a/src/common/protocol.c +++ b/src/common/protocol.c @@ -17,11 +17,13 @@ along with DistRen. If not, see . */ -#include "protocol.h" -#include "remoteio.h" +#include "common/config.h" -#include +#include "common/protocol.h" +#include "common/remoteio.h" + #include +#include #include #define DISTREN_REQUEST_MAGIC ((uint32_t)0x32423434) diff --git a/src/common/remoteio.c b/src/common/remoteio.c --- a/src/common/remoteio.c +++ b/src/common/remoteio.c @@ -18,9 +18,11 @@ */ -#include "libremoteio.h" -#include "execio.h" -#include "asprintf.h" +#include "common/config.h" + +#include "common/libremoteio.h" +#include "common/execio.h" +#include "common/asprintf.h" #include @@ -116,12 +118,12 @@ int remoteio_config(cfg_t *cfg, struct r multiio_event_handler_register(opts->multiio, opts->socket_type, - POLLWRNORM, + POLLOUT, (multiio_event_handler_func_t)&_remoteio_handle_write, opts); multiio_event_handler_register(opts->multiio, opts->socket_type, - POLLRDNORM, + POLLIN, (multiio_event_handler_func_t)&_remoteio_handle_read, opts); @@ -224,7 +226,7 @@ int remoteio_open_socket(struct remoteio rem = *remoteio; rem->sock = fd; - multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLRDNORM); + multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLIN); return 0; } @@ -281,7 +283,7 @@ int remoteio_open_server(struct remoteio * execio's multi-sockets by letting execio register itself with * multiio instead of us registering here perhaps */ - multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLRDNORM); + multiio_socket_add(opts->multiio, rem->sock, opts->socket_type, rem, POLLIN); return 0; } @@ -371,10 +373,10 @@ int remoteio_write(struct remoteio *rem, if(q_empty(rem->outmsgs)) { pollfd.fd = rem->sock; - pollfd.revents = POLLWRNORM; + pollfd.revents = POLLOUT; pollfd.events = 0; poll(&pollfd, 1, 0); - if(pollfd.events & POLLWRNORM) + if(pollfd.events & POLLOUT) { bytes_written = write(rem->sock, buf, len); if(bytes_written > 0) @@ -411,7 +413,7 @@ int remoteio_write(struct remoteio *rem, memcpy(packet->data, buf, len); q_enqueue(rem->outmsgs, packet, 0); - multiio_socket_event_enable(rem->opts->multiio, rem->sock, POLLWRNORM); + multiio_socket_event_enable(rem->opts->multiio, rem->sock, POLLOUT); return 0; } @@ -435,7 +437,7 @@ int _remoteio_handle_write(multiio_conte */ if(q_empty(rem->outmsgs)) { - multiio_socket_event_disable(multiio, fd, POLLWRNORM); + multiio_socket_event_disable(multiio, fd, POLLOUT); return 0; } @@ -455,7 +457,7 @@ int _remoteio_handle_write(multiio_conte remoteio_packet_free(packet); if(q_empty(rem->outmsgs)) - multiio_socket_event_disable(multiio, fd, POLLWRNORM); + multiio_socket_event_disable(multiio, fd, POLLOUT); } else { diff --git a/src/common/request.c b/src/common/request.c --- a/src/common/request.c +++ b/src/common/request.c @@ -17,6 +17,8 @@ * along with DistRen. If not, see . */ +#include "common/config.h" + #include "common/protocol.h" #include diff --git a/src/server/distrend.c b/src/server/distrend.c --- a/src/server/distrend.c +++ b/src/server/distrend.c @@ -20,6 +20,8 @@ /* This file contains the code which both processes (renders) jobs as a slave, and the code which distributes frames to slaves after receiving them from the client portion of the codebase. */ +#include "common/config.h" + #include "distrenjob.h" #include "listen.h" #include "slavefuncs.h" @@ -31,7 +33,6 @@ #include "common/protocol.h" #include -#include #include #include #include diff --git a/src/server/distrenjob.c b/src/server/distrenjob.c --- a/src/server/distrenjob.c +++ b/src/server/distrenjob.c @@ -17,6 +17,8 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "distrenjob.h" #include "slavefuncs.h" @@ -25,6 +27,7 @@ #include #include #include +#include void distrenjob_free(struct distrenjob **distrenjob) { diff --git a/src/server/listen.c b/src/server/listen.c --- a/src/server/listen.c +++ b/src/server/listen.c @@ -17,15 +17,18 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "listen.h" + #include "common/protocol.h" #include "common/remoteio.h" #include #include -#include #include #include +#include #include #include #include @@ -103,7 +106,7 @@ struct distrend_listens *distrend_listen listens); multiio_event_handler_register(multiio, listens->socket_type, - POLLRDNORM, + POLLIN, (multiio_event_handler_func_t)&listen_handle_accept, listens); @@ -156,7 +159,7 @@ int distrend_listen_add(struct distrend_ } *saved_port = port; - tmp = multiio_socket_add(listens->multiio, fd, listens->socket_type, saved_port, POLLRDNORM); + tmp = multiio_socket_add(listens->multiio, fd, listens->socket_type, saved_port, POLLIN); if(tmp) { close(fd); diff --git a/src/server/mysql.c b/src/server/mysql.c --- a/src/server/mysql.c +++ b/src/server/mysql.c @@ -18,6 +18,8 @@ */ +#include "common/config.h" + #include "mysql.h" #include diff --git a/src/server/simpleslave.c b/src/server/simpleslave.c --- a/src/server/simpleslave.c +++ b/src/server/simpleslave.c @@ -18,6 +18,8 @@ */ +#include "common/config.h" + #include "slavefuncs.h" #include "common/asprintf.h" diff --git a/src/server/slave.c b/src/server/slave.c --- a/src/server/slave.c +++ b/src/server/slave.c @@ -18,6 +18,8 @@ */ +#include "common/config.h" + #include "slavefuncs.h" #include "common/asprintf.h" diff --git a/src/server/slavefuncs.c b/src/server/slavefuncs.c --- a/src/server/slavefuncs.c +++ b/src/server/slavefuncs.c @@ -17,6 +17,8 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "distrenjob.h" #include "slavefuncs.h" diff --git a/src/server/tabletennis.c b/src/server/tabletennis.c --- a/src/server/tabletennis.c +++ b/src/server/tabletennis.c @@ -17,6 +17,8 @@ * along with DistRen. If not, see . */ +#include "common/config.h" + #include "distrend.h" #include "listen.h" #include "tabletennis.h" diff --git a/src/server/user_mgr.c b/src/server/user_mgr.c --- a/src/server/user_mgr.c +++ b/src/server/user_mgr.c @@ -17,6 +17,8 @@ along with DistRen. If not, see . */ +#include "common/config.h" + #include "user_mgr.h" #include "common/asprintf.h" @@ -29,7 +31,6 @@ #include #include -#include #include #include #include @@ -80,8 +81,10 @@ struct user *findUser(char *nameOfUser) int low; int middle; int result; + high = user_mgr_info.user_array_size - 1; low = 0; + result = -1; for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2) { @@ -89,9 +92,9 @@ struct user *findUser(char *nameOfUser) while(user_mgr_info.user_array[middle].username == 0) { if(result < 0) - middle--; + middle --; else - middle++; + middle ++; } // this is where the array is cut in half and the half that the nameOfUser is on is kept @@ -142,6 +145,8 @@ int placeUser(int index, char *nameOfUse int lower; int total_moves; + total_moves = 0; + // I shift data in the array to create an open the space where the user should be added // but first I figure out which way is the shortest if(user_mgr_info.user_array[index].username != 0) @@ -172,9 +177,9 @@ int placeUser(int index, char *nameOfUse // add the user to the array createUser(&user_mgr_info.user_array[index], nameOfUser); - if(total_moves > 50){ + if(total_moves > 50) resize_user_array(); - } + return 1; } @@ -184,8 +189,10 @@ int addUser(char *nameOfUser) int low; int middle; int result; + high = user_mgr_info.user_array_size - 1; low = 0; + result = -1; for(middle = (low+high)/2; 1 == 1; middle = (low+high)/2) {