~aritra1911/mc_server

d753acf708caf0709a4fcfa133a0bf68879d9566 — Aritra Sarkar 1 year, 11 months ago 678cde9
Test on Minix 3.3.0 i386
6 files changed, 23 insertions(+), 22 deletions(-)

M .gitignore
M Makefile
M autodetect.sh
M main.c
M response.c
M tpool.c
M .gitignore => .gitignore +1 -0
@@ 2,5 2,6 @@
*.d
*.swp
*.core
core.*
server
config.mk

M Makefile => Makefile +10 -5
@@ 3,9 3,12 @@
PROGS				=	server

CFLAGS				=	-std=iso9899:1999 -pedantic -pedantic-errors -Wall -Wextra \
					-Werror-implicit-function-declaration -Wno-reserved-id-macro \
					-Wno-missing-prototypes -Wno-thread-safety-analysis -Wno-padded \
					-Wno-cast-align -Wno-comma -g -O0 -fno-fast-math -fno-builtin
					-Werror-implicit-function-declaration \
					-Wno-unknown-warning-option -Wno-reserved-id-macro \
					-Wno-reserved-identifier -Wno-disabled-macro-expansion \
					-Wno-missing-prototypes -Wno-thread-safety-analysis \
					-Wno-return-type -Wno-padded -Wno-cast-align -Wno-comma \
					-g -O0 -fno-fast-math -fno-builtin

CFLAGS_x86_64-linux-gcc		=	-m64
CFLAGS_i686-linux-gcc		=	-m32


@@ 13,11 16,13 @@ CFLAGS_x86_64-linux-clang	=	-Weverything -m64
CFLAGS_i686-linux-clang		=	-Weverything -m32
CFLAGS_amd64-freebsd-clang	=	-Weverything -m64
CFLAGS_i686-freebsd-clang	=	-Weverything -m32
CFLAGS_i386-minix-clang		=	-Weverything -m32

CPPFLAGS			=	-D_XOPEN_SOURCE=600 -D_POSIX_PTHREAD_SEMANTICS \
CPPFLAGS			=	-I/usr/local/include -I/usr/pkg/include \
					-D_XOPEN_SOURCE=600 -D_POSIX_PTHREAD_SEMANTICS \
					-D_LARGEFILE64_SOURCE

LDFLAGS				=	-pthread
LDFLAGS				=	-L/usr/local/lib -L/usr/pkg/lib -pthread

server_SRCS			=	main.c session.c response.c tpool.c events.c helpers.c


M autodetect.sh => autodetect.sh +1 -10
@@ 66,16 66,7 @@ compiler_flags() {
linker_flags() {
    checking "link stage flags"

    case "${CCNAME}" in
        sunstudio)
            LINK_FLAGS="\${COMPILE_FLAGS}"
            ;;
        *)
            LINK_FLAGS="\${CFLAGS} \${CPPFLAGS}"
            ;;
    esac

    dump "LINK_FLAGS=${LINK_FLAGS} \${LDFLAGS} \${LDFLAGS_${TARGET}} \${LIB_LDFLAGS} \${\${@}_LDFLAGS}"
    dump "LINK_FLAGS=\${LDFLAGS} \${LDFLAGS_${TARGET}} \${LIB_LDFLAGS} \${\${@}_LDFLAGS}"
    checking_result "ok"
}


M main.c => main.c +1 -1
@@ 315,7 315,7 @@ main(int argc, char **argv)
        goto destroy_session_and_exit;
    }

    printf("INFO : Initialized thread pool with %lu worker threads.\n",
    printf("INFO : Initialized thread pool with %zu worker threads.\n",
                   tpool.num_threads);

    printf("INFO : Listening for connections on port %s\n", prefs.port);

M response.c => response.c +9 -5
@@ 139,9 139,13 @@ respond(client_t *client, const client_t *clients_list, size_t list_size,
        return append_nick(RES_QUIT, client->nick, buf, len, err_code);
    }

    /* Invalid send code */
    if ( err_code )
        *err_code = IN_SEND_CODE;

    return -1;
    /* Uncomment this if the above switch is not handling all possible
     * cases
     *
     * Invalid send code *
     * if ( err_code )
     *     *err_code = IN_SEND_CODE;
     *
     * return -1;
     */
}

M tpool.c => tpool.c +1 -1
@@ 396,7 396,7 @@ tpool_destroy(tpool_t *tpoolp, int finish)
    if ( finish ) {
        if ( tpoolp->cur_queue_size )
            printf("DBUG : Waiting for worker threads to drain work queue.\n"
                   "     : Work queue size = %li\n", tpoolp->cur_queue_size);
                   "     : Work queue size = %zu\n", tpoolp->cur_queue_size);
        while ( tpoolp->cur_queue_size ) {
            if ( pthread_cond_wait(&tpoolp->queue_empty,
                                   &tpoolp->queue_lock) ) {