diff options
Diffstat (limited to 'net-p2p/dctc/files')
-rw-r--r-- | net-p2p/dctc/files/lp_mutex.c | 119 | ||||
-rw-r--r-- | net-p2p/dctc/files/patch-src::dc_manage.c | 77 | ||||
-rw-r--r-- | net-p2p/dctc/files/patch-src::main.c | 10 | ||||
-rw-r--r-- | net-p2p/dctc/files/patch-src::mydb.c | 28 | ||||
-rw-r--r-- | net-p2p/dctc/files/patch-src::sema.c | 158 |
5 files changed, 0 insertions, 392 deletions
diff --git a/net-p2p/dctc/files/lp_mutex.c b/net-p2p/dctc/files/lp_mutex.c deleted file mode 100644 index 036b004e23dc..000000000000 --- a/net-p2p/dctc/files/lp_mutex.c +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 - * Mario Sergio Fujikawa Ferreira <lioux@FreeBSD.org> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD - */ - - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif - -#ifdef HAVE_SYS_PARAM_H -# include <sys/param.h> -#endif - -#include <stdlib.h> - -# include <pthread.h> - -/* - * Use a mutex under BSD systems to avoid problems with semaphores - * blocking all the threads since BSD have MIT pthreads user space - * threads. If not BSD, use some stubs that do nothing. Since these - * stubs are empty, most modern compilers will simply add a NOP at - * the calling point. - */ -# if (defined(BSD) && (BSD >= 199103)) -int -lp_mutex_init_ (pthread_mutex_t ** mutex, - const pthread_mutexattr_t *attr) -{ - pthread_mutex_t * mutex_temp; - - if ( (mutex_temp = \ - (pthread_mutex_t *) malloc (sizeof(pthread_mutex_t))) ) { - - if ( (pthread_mutex_init(mutex_temp, attr)) == 0) { - - (*mutex) = mutex_temp; - return (1); - } else { - return (0); - } - } else { - /* Not enough memory */ - return (-1); - } -} - -int -lp_mutex_lock_ (pthread_mutex_t * mutex) -{ - if ( (pthread_mutex_lock(mutex)) == 0) { - return (1); - } else { - return (0); - } -} - -int -lp_mutex_unlock_ (pthread_mutex_t * mutex) -{ - if ( (pthread_mutex_unlock(mutex)) == 0) { - return (1); - } else { - return (0); - } -} - -int -lp_mutex_destroy_ (pthread_mutex_t ** mutex) -{ - if ( (pthread_mutex_destroy(*mutex)) == 0) { - free (*mutex); - return (1); - } else { - return (0); - } -} - -# else /* !(defined(BSD) && (BSD >= 199103)) */ - -int -lp_mutex_init_ (pthread_mutex_t ** mutex, - const pthread_mutexattr_t *attr) {} - -int -lp_mutex_lock_ (pthread_mutex_t * mutex) {} - -int -lp_mutex_unlock_ (pthread_mutex_t * mutex) {} - -int -lp_mutex_destroy_ (pthread_mutex_t ** mutex) {} - -# endif /* (defined(BSD) && (BSD >= 199103)) */ diff --git a/net-p2p/dctc/files/patch-src::dc_manage.c b/net-p2p/dctc/files/patch-src::dc_manage.c deleted file mode 100644 index b9475fd2baf4..000000000000 --- a/net-p2p/dctc/files/patch-src::dc_manage.c +++ /dev/null @@ -1,77 +0,0 @@ ---- src/dc_manage.c.orig Mon Jul 22 13:20:19 2002 -+++ src/dc_manage.c Mon Jul 22 18:18:40 2002 -@@ -554,18 +554,6 @@ - - unconvert_path(fullpathname); - -- if(!file_in_db(fullpathname,&virtual)) /* is it a shared file ? */ -- { -- GString *err_msg; -- -- err_msg=g_string_new("$Error "); -- g_string_sprintfa(err_msg,"%s no more exists",fullpathname); -- disp_msg(DEBUG_MSG,"com_up_get_process","file not found",err_msg->str,NULL); -- send_dc_line(sck,err_msg->str,NULL); -- g_string_free(err_msg,TRUE); -- return 1; -- } -- - if(hide_absolute==0) - { - if(((unsigned char)fullpathname[0])==255) -@@ -580,6 +568,18 @@ - fullpathname[0]='/'; - } - -+ if(!file_in_db(fullpathname,&virtual)) /* is it a shared file ? */ -+ { -+ GString *err_msg; -+ -+ err_msg=g_string_new("$Error "); -+ g_string_sprintfa(err_msg,"%s no more exists",fullpathname); -+ disp_msg(DEBUG_MSG,"com_up_get_process","file not found",err_msg->str,NULL); -+ send_dc_line(sck,err_msg->str,NULL); -+ g_string_free(err_msg,TRUE); -+ return 1; -+ } -+ - /* it is time to verify if a slot is available */ - LOCK_WRITE(user_info); - if((dl_on==0)||(virtual!=0)) -@@ -743,18 +743,6 @@ - - unconvert_path(fullpathname); - -- if(!file_in_db(fullpathname,&virtual)) /* is it a shared file ? */ -- { -- GString *err_msg; -- -- err_msg=g_string_new("$Error "); -- g_string_sprintfa(err_msg,"%s no more exists",fullpathname); -- disp_msg(DEBUG_MSG,"com_up_getfilelength_process","file not found",err_msg->str,NULL); -- send_dc_line(sck,err_msg->str,NULL); -- g_string_free(err_msg,TRUE); -- return 1; -- } -- - if(hide_absolute==0) - { - if(((unsigned char)fullpathname[0])==255) -@@ -769,6 +757,17 @@ - fullpathname[0]='/'; - } - -+ if(!file_in_db(fullpathname,&virtual)) /* is it a shared file ? */ -+ { -+ GString *err_msg; -+ -+ err_msg=g_string_new("$Error "); -+ g_string_sprintfa(err_msg,"%s no more exists",fullpathname); -+ disp_msg(DEBUG_MSG,"com_up_getfilelength_process","file not found",err_msg->str,NULL); -+ send_dc_line(sck,err_msg->str,NULL); -+ g_string_free(err_msg,TRUE); -+ return 1; -+ } - - if(send_file_length(sck,fullpathname,&file_len)) - { diff --git a/net-p2p/dctc/files/patch-src::main.c b/net-p2p/dctc/files/patch-src::main.c deleted file mode 100644 index 25a38d699d89..000000000000 --- a/net-p2p/dctc/files/patch-src::main.c +++ /dev/null @@ -1,10 +0,0 @@ ---- src/main.c.orig Sun Sep 29 14:07:48 2002 -+++ src/main.c Sun Sep 29 14:08:52 2002 -@@ -1269,6 +1269,7 @@ - - char *virtual_share_path=NULL; - -+ hide_absolute=1; - disp_msg(INFO_MSG,NULL,"Direct Connect Text Client v" VERSION ,NULL); - - if(argc==1) diff --git a/net-p2p/dctc/files/patch-src::mydb.c b/net-p2p/dctc/files/patch-src::mydb.c deleted file mode 100644 index ab57f7bb2f50..000000000000 --- a/net-p2p/dctc/files/patch-src::mydb.c +++ /dev/null @@ -1,28 +0,0 @@ ---- src/mydb.c.orig Mon Jul 22 13:48:07 2002 -+++ src/mydb.c Mon Jul 22 19:21:42 2002 -@@ -1141,6 +1141,16 @@ - int file_in_db(char *filename, int *virtual) - { - int i; -+ char *filename_internal; -+ -+ if ((filename != NULL) && (filename[0]=='/')) -+ { -+ if(hide_absolute==0) -+ filename_internal=filename; -+ else -+ filename_internal=filename+1; -+ } else -+ filename_internal=filename; - - G_LOCK(shared_info); - if(shared_info!=NULL) -@@ -1151,7 +1161,7 @@ - - /* DB_ENTRY to compare */ - de=&(g_array_index(shared_info,DB_ENTRY,i)); -- if(!strcmp(de->filename,filename)) -+ if(!strcmp(de->filename,filename_internal)) - { - *virtual=de->virtual; - G_UNLOCK(shared_info); diff --git a/net-p2p/dctc/files/patch-src::sema.c b/net-p2p/dctc/files/patch-src::sema.c deleted file mode 100644 index 60ae0eb570c5..000000000000 --- a/net-p2p/dctc/files/patch-src::sema.c +++ /dev/null @@ -1,158 +0,0 @@ ---- src/sema.c.orig Sun Jul 21 21:13:59 2002 -+++ src/sema.c Mon Jul 22 19:30:15 2002 -@@ -22,6 +22,10 @@ - # include <config.h> - #endif - -+#ifdef HAVE_SYS_PARAM_H -+# include <sys/param.h> -+#endif -+ - #include <stdio.h> - #include <stdlib.h> - #include <unistd.h> -@@ -57,6 +61,11 @@ - #include "uaddr.h" - #include "status.h" - -+/* interval between busy wait tries measured in microseconds */ -+#define MUTEX_BUSY_WAIT_TIME 5000 -+ -+pthread_mutex_t *semaphore_mutex = PTHREAD_MUTEX_INITIALIZER; -+ - /***********************************************************************/ - /* the following functions manage the bandwidth upload limit */ - /* The system is build on 2 semaphores and 1 file */ -@@ -100,6 +109,8 @@ - - int semid; - -+ lp_mutex_init_(&semaphore_mutex, NULL); -+ - fd=open(keyfile,O_CREAT|O_WRONLY|O_EXCL,0600); /* create the file if not exists */ - if(fd==-1) - { -@@ -131,7 +142,11 @@ - { - close(fd); - /* a key exist */ -+#if !(defined(BSD) && (BSD >= 199103)) - semid=semget(key,0,IPC_ALLOC); -+#else -+ semid=semget(key,0,IPC_STAT); -+#endif - if(semid==-1) - goto create_new_sema; - printf("current sema found.\n"); -@@ -293,8 +308,13 @@ - void check_sema_master(int semid) - { - struct sembuf sb={0,-1,IPC_NOWAIT|SEM_UNDO}; /* master sema */ -+ int result; -+ -+ (void) lp_mutex_lock_(semaphore_mutex); -+ result = semop(semid,&sb,1); -+ (void) lp_mutex_unlock_(semaphore_mutex); - -- if(semop(semid,&sb,1)==0) -+ if (result==0) - { - /* to get slice, the function checks if the clock thread still runs */ - create_sema_master(semid); -@@ -308,15 +328,29 @@ - /*******************************************/ - void get_slice(int semid, SPD_SEMA semnum) - { -+#if !(defined(BSD) && (BSD >= 199103)) -+ struct sembuf local={0,-1,0}; /* slave sema */ -+#else -+ struct sembuf local={0,-1,0|IPC_NOWAIT}; /* slave sema */ -+#endif -+ local.sem_num=semnum; -+ -+ (void) lp_mutex_lock_(semaphore_mutex); - while(1) - { -- struct sembuf local={0,-1,0}; /* slave sema */ -- -- local.sem_num=semnum; -- if(semop(semid,&local,1)==0) -- { -- /* we have what we want */ -- return; -+ switch (semop(semid,&local,1)) { -+ case 0: (void) lp_mutex_unlock_(semaphore_mutex); -+ /* we have what we want */ -+ return; -+ break; -+ case -1: switch(errno) { -+ case EAGAIN: /* triggers busy wait */ -+ case EINTR: /* interrupted by system call, try again */ -+ pthread_yield(); -+ usleep(MUTEX_BUSY_WAIT_TIME); /* busy wait with a small time out */ -+ continue; -+ break; -+ } - } - } - } -@@ -368,9 +402,26 @@ - /******************************/ - void lock_ul_slot_controler(int semid) - { -+#if !(defined(BSD) && (BSD >= 199103)) - struct sembuf get_ul_ctrl={UL_SLOT_SEMA,-1,SEM_UNDO}; -+#else -+ struct sembuf get_ul_ctrl={UL_SLOT_SEMA,-1,SEM_UNDO|IPC_NOWAIT}; -+#endif -+ -+ (void) lp_mutex_lock_(semaphore_mutex); -+repeat: - /* lock the UL slot controler */ -- semop(semid,&get_ul_ctrl,1); -+ if (semop(semid,&get_ul_ctrl,1)==-1) -+ switch(errno) -+ { -+ case EAGAIN: /* triggers busy wait */ -+ case EINTR: /* interrupted by system call, try again */ -+ pthread_yield(); -+ usleep(MUTEX_BUSY_WAIT_TIME); /* busy wait with a small time out */ -+ goto repeat; -+ break; -+ } -+ (void) lp_mutex_unlock_(semaphore_mutex); - } - - /*********************************/ -@@ -526,11 +577,28 @@ - perror("free_one_ul_slot"); - } - #else -+# if !(defined(BSD) && (BSD >= 199103)) - struct sembuf free_one_ul_slot_op={UL_SLOT_BUSY_SEMA,-1,SEM_UNDO}; -- if(semop(semid,&free_one_ul_slot_op,1)==-1) -- { -- perror("free_one_ul_slot"); -+# else -+ struct sembuf free_one_ul_slot_op={UL_SLOT_BUSY_SEMA,-1,SEM_UNDO|IPC_NOWAIT}; -+# endif -+ -+ (void) lp_mutex_lock_(semaphore_mutex); -+repeat: -+ if(semop(semid,&free_one_ul_slot_op,1)==-1) { -+ switch(errno) { -+ case EAGAIN: /* triggers busy wait */ -+ case EINTR: /* interrupted by system call, try again */ -+ pthread_yield(); -+ usleep(MUTEX_BUSY_WAIT_TIME); /* busy wait with a small time out */ -+ goto repeat; -+ break; -+ default: -+ perror("free_one_ul_slot"); -+ break; -+ } - } -+ (void) lp_mutex_unlock_(semaphore_mutex); - #endif - nb_local_ul--; - } |