1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-22 08:58:47 +00:00

o Update to 0.61

o Greatly simplify the patches removing sigprocmask protection
  around send/receive since there is already a global signal handler
This commit is contained in:
Mario Sergio Fujikawa Ferreira 2001-12-02 21:54:10 +00:00
parent cfaf7af6f0
commit 6452587524
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=50905
22 changed files with 148 additions and 826 deletions

View File

@ -6,10 +6,10 @@
#
PORTNAME= dctc
PORTVERSION= 0.60
PORTVERSION= 0.61
CATEGORIES= net
MASTER_SITES= http://ac2i.tzo.com/dctc/
DISTNAME= ${PORTNAME}_v${PORTVERSION}
DISTNAME= ${PORTNAME}-${PORTVERSION}
MAINTAINER= lioux@FreeBSD.org
@ -34,6 +34,7 @@ post-patch:
@${PERL} -pi -e 's/(CK?\(std)(out\))/\1_\2/' ${BUILD_WRKSRC}/*
do-configure:
@${CP} ${FILESDIR}/config.h ${BUILD_WRKSRC}
@cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} depend
do-install:

View File

@ -1 +1 @@
MD5 (dctc_v0.60.tar.gz) = 0fe566ab242528833a5640cfb5a74257
MD5 (dctc-0.61.tar.gz) = 88606bb7a92e4b84af20fe6e92cfe1d2

View File

@ -0,0 +1,30 @@
#ifndef ___CONFIG_H___
#define ___CONFIG_H___
/* To enable detecting of BSD systems */
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
/* For BSD */
#if (defined(BSD) && (BSD >= 199103))
# include <sys/ipc.h>
# include <sys/sem.h>
#else
/* For linux */
# include <linux/sem.h> /* for the value of SEMVMX */
#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
#ifndef SEMVMX
/* this value comes from linux/sem.h */
#define SEMVMX 32767
#endif
#endif /* ___CONFIG_H___ */

View File

@ -1,10 +1,10 @@
--- src/Makefile.orig Sat Nov 24 13:20:21 2001
+++ src/Makefile Sat Nov 24 13:20:34 2001
--- src/Makefile Sun Nov 25 07:37:30 2001
+++ src/Makefile Sun Dec 2 19:34:46 2001
@@ -1,6 +1,6 @@
#CC = gcc
-CFLAGS =-g -march=i586 -O2 -Wall `glib-config --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings #-Wshadow
-LDFLAGS = -g `glib-config --libs glib gthread`
+CFLAGS +=-g -Wall `${GLIB_CONFIG} --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings -I${LOCALBASE}/include ${PTHREAD_CFLAGS}
+CFLAGS += -g -Wall `${GLIB_CONFIG} --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings -I${LOCALBASE}/include ${PTHREAD_CFLAGS}
+LDFLAGS += -g `${GLIB_CONFIG} --libs glib gthread` ${PTHREAD_LIBS}
CSRC = main.c action.c dc_com.c display.c key.c keyboard.c network.c typical_action.c dc_manage.c db.c he3.c gts.c user_manage.c md.c timed_out_string.c sema.c

View File

@ -1,69 +1,11 @@
--- src/db.c.orig Thu Nov 22 00:08:34 2001
+++ src/db.c Thu Nov 22 00:11:49 2001
@@ -30,6 +30,15 @@
--- src/db.c Mon Nov 26 16:28:32 2001
+++ src/db.c Sun Dec 2 19:34:12 2001
@@ -30,6 +30,8 @@
#include <netinet/in.h>
#include <glib.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+#include "config.h"
+
#include "db.h"
#include "display.h"
#include "var.h"
@@ -711,6 +720,9 @@
/******************************************************************************************/
static void send_a_db_result(int output_sck, char *dest_nick, DB_ENTRY *de, struct sockaddr_in *dest_addr, char *md5sum)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
GString *str;
GString *adapted;
@@ -752,10 +764,38 @@
printf("dest_addr: %s, str: %s\n",dest_addr,str->str);
#endif
- if(dest_addr==NULL)
+ if(dest_addr==NULL) {
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
send(output_sck,str->str,str->len,MSG_NOSIGNAL);
- else
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ } else {
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
sendto(output_sck,str->str,str->len,MSG_NOSIGNAL,(void*)dest_addr, sizeof(struct sockaddr_in));
+
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ }
disp_msg(INFO_MSG,"send_search_result_line",str->str,NULL);

View File

@ -1,52 +1,11 @@
--- src/dc_com.c.orig Thu Nov 22 00:12:50 2001
+++ src/dc_com.c Thu Nov 22 00:15:55 2001
@@ -33,6 +33,15 @@
--- src/dc_com.c Sat Oct 20 03:46:54 2001
+++ src/dc_com.c Sun Dec 2 19:34:12 2001
@@ -28,6 +28,8 @@
#include <errno.h>
#include <glib.h>
+#include "config.h"
+
#include "dc_com.h"
#include "display.h"
#include "main.h"
#include "var.h"
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+
char last_cmd[5120]; /* contains the first string of the last send_dc_line call */
/* mainly used for debug features. */
time_t last_cmd_time;
@@ -50,6 +59,10 @@
/***********************************************************/
void send_dc_line(int sck,...)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+ ssize_t send_return;
+#endif
va_list ap;
char *t;
int have=0;
@@ -84,7 +97,21 @@
if((str->len)&&(cnx_in_progress==0))
{
- if(send(sck,str->str,str->len,MSG_NOSIGNAL)!=str->len)
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
+ send_return = send(sck,str->str,str->len, MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ if(send_return!=str->len)
{
/* abort network operation on this socket */
/* this will either generated a hub_disconnection message (main thread) */

View File

@ -1,5 +1,5 @@
--- src/dc_com.h.orig Wed Nov 21 22:15:21 2001
+++ src/dc_com.h Wed Nov 21 22:15:32 2001
--- src/dc_com.h Sat Oct 20 03:32:19 2001
+++ src/dc_com.h Sun Dec 2 19:34:12 2001
@@ -21,6 +21,8 @@
#ifndef __DC_COM_H__
#define __DC_COM_H__

View File

@ -1,264 +1,11 @@
--- src/dc_manage.c.orig Sat Nov 24 08:43:42 2001
+++ src/dc_manage.c Sat Nov 24 13:17:32 2001
@@ -35,6 +35,11 @@
--- src/dc_manage.c Sat Dec 1 08:45:25 2001
+++ src/dc_manage.c Sun Dec 2 19:34:12 2001
@@ -35,6 +35,8 @@
#include <fcntl.h>
#include <pthread.h>
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+#include "config.h"
+
#include "display.h"
#include "action.h"
#include "macro.h"
@@ -189,6 +194,9 @@
/*************************/
static int send_file_data(int sck,char *filename, int start_pos, unsigned long file_len,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
unsigned long int i;
char buf[8192]; /* must be a multiple of 512 */
unsigned long int a=file_len-start_pos;
@@ -220,7 +228,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,sizeof(buf)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,buf,sizeof(buf),MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=sizeof(buf))
@@ -240,7 +261,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,buf,remain,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=remain)
@@ -259,6 +293,9 @@
/*************************/
static int send_array_data(int sck,GByteArray *ba,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
unsigned long int i;
unsigned long int nb;
int remain;
@@ -274,7 +311,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,BLOCK_SIZE/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,ba->data+cur_pos,BLOCK_SIZE,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=BLOCK_SIZE)
@@ -292,7 +342,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,ba->data+cur_pos,remain,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=remain)
@@ -326,6 +389,9 @@
/**************************************************************************/
static int com_up_get_list_len_process(const char *cmd,WAIT_ACT *act,int sck,GString *input, char *xtra_param)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
GByteArray *cpy_data;
GString *out;
int res;
@@ -377,7 +443,20 @@
disp_msg(DEBUG_MSG,"reply",out->str,NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,out->str,out->len,MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
res=(res!=out->len);
g_string_free(out,TRUE);
if(res)
@@ -403,7 +482,20 @@
g_string_sprintfa(out,"%lu|",(unsigned long)100000+rand()%500000);
else
g_string_sprintfa(out,"%lu|",(unsigned long)cpy_data->len);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,out->str,out->len,MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
res=(res!=out->len);
g_string_free(out,TRUE);
if(res)
@@ -674,6 +766,9 @@
/*****************************************************************/
static int copie_fd_to_file(int remote, FILE *local, unsigned long amount,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
while(amount!=0)
{
char buf[8192];
@@ -684,7 +779,20 @@
/* touch the action slot to avoid timeout */
act->last_touch=time(NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
ret=recv(remote,buf,nb,MSG_WAITALL|MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if((ret==-1)||(ret==0))
@@ -1019,6 +1127,9 @@
/*****************************************************************/
static int copie_fd_to_bytearray(int remote, GByteArray **ba, unsigned long amount,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
int pos=0;
int ret;
unsigned long nb;
@@ -1032,12 +1143,25 @@
/* touch the action slot to avoid timeout */
act->last_touch=time(NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
#if 0
ret=recv(remote,(*ba)->data+pos,nb,MSG_WAITALL|MSG_NOSIGNAL);
#else
ret=recv(remote,(*ba)->data+pos,nb,MSG_NOSIGNAL);
printf("%d\n",ret);
#endif
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if((ret==-1)||(ret==0))
@@ -2674,10 +2798,26 @@
/*******************************************************/
int manage_srch_port(int srch_sck, int sck)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
char buf[8192];
int ret;
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
ret=recv(srch_sck,buf,sizeof(buf),MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
if(ret!=-1)
{
int i;

View File

@ -1,14 +1,16 @@
--- src/keyboard.c.orig Sat Nov 24 13:29:15 2001
+++ src/keyboard.c Sat Nov 24 13:43:51 2001
@@ -31,6 +31,7 @@
--- src/keyboard.c Sat Dec 1 08:53:15 2001
+++ src/keyboard.c Sun Dec 2 19:34:12 2001
@@ -31,6 +31,9 @@
#include <netdb.h>
#include <glib.h>
+#include "config.h"
+
+#if !(defined(BSD) && (BSD >= 199103))
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#else
@@ -42,6 +43,7 @@
@@ -42,6 +45,7 @@
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif

View File

@ -1,6 +1,6 @@
--- src/main.c.orig Sat Nov 24 13:22:57 2001
+++ src/main.c Sat Nov 24 13:25:24 2001
@@ -30,12 +30,23 @@
--- src/main.c Sat Dec 1 09:05:19 2001
+++ src/main.c Sun Dec 2 19:34:12 2001
@@ -30,12 +30,13 @@
#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/un.h>
@ -11,17 +11,7 @@
#include <glib.h>
#include <pthread.h>
+
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+# include <sys/ipc.h>
+# include <sys/sem.h>
+#else
+/* For linux */
+# include <linux/sem.h> /* for the value of SEMVMX */
+#endif
+#include "config.h"
#include "var.h"
#include "display.h"

View File

@ -1,18 +1,17 @@
--- src/sema.c.orig Sat Nov 24 13:48:16 2001
+++ src/sema.c Sat Nov 24 14:53:39 2001
@@ -31,6 +31,11 @@
--- src/sema.c Sat Nov 24 08:29:56 2001
+++ src/sema.c Sun Dec 2 19:34:12 2001
@@ -29,8 +29,10 @@
#include <limits.h>
#include <pthread.h>
+#include "config.h"
#include "sema.h"
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if !(defined(BSD) && (BSD >= 199103))
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#else
@@ -42,6 +47,7 @@
@@ -42,6 +44,7 @@
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif
@ -20,12 +19,3 @@
#ifndef IPC_ALLOC
#define IPC_ALLOC 0
@@ -201,7 +207,7 @@
pthread_attr_init (&thread_attr);
pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&thread_id,&thread_attr, (void*)sema_master,(void*)semid)!=0)
+ if(pthread_create(&thread_id,&thread_attr, sema_master,(void*)semid)!=0)
{
/* if the creation of the clock thread fails, release the master sema */
/* else nobody will try to create a new clock and all xfers will hang */

View File

@ -6,10 +6,10 @@
#
PORTNAME= dctc
PORTVERSION= 0.60
PORTVERSION= 0.61
CATEGORIES= net
MASTER_SITES= http://ac2i.tzo.com/dctc/
DISTNAME= ${PORTNAME}_v${PORTVERSION}
DISTNAME= ${PORTNAME}-${PORTVERSION}
MAINTAINER= lioux@FreeBSD.org
@ -34,6 +34,7 @@ post-patch:
@${PERL} -pi -e 's/(CK?\(std)(out\))/\1_\2/' ${BUILD_WRKSRC}/*
do-configure:
@${CP} ${FILESDIR}/config.h ${BUILD_WRKSRC}
@cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} ${MAKE} depend
do-install:

View File

@ -1 +1 @@
MD5 (dctc_v0.60.tar.gz) = 0fe566ab242528833a5640cfb5a74257
MD5 (dctc-0.61.tar.gz) = 88606bb7a92e4b84af20fe6e92cfe1d2

30
net/dctc/files/config.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef ___CONFIG_H___
#define ___CONFIG_H___
/* To enable detecting of BSD systems */
#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endif
#include <sys/types.h>
#include <sys/socket.h>
/* For BSD */
#if (defined(BSD) && (BSD >= 199103))
# include <sys/ipc.h>
# include <sys/sem.h>
#else
/* For linux */
# include <linux/sem.h> /* for the value of SEMVMX */
#endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
#ifndef SEMVMX
/* this value comes from linux/sem.h */
#define SEMVMX 32767
#endif
#endif /* ___CONFIG_H___ */

View File

@ -1,10 +1,10 @@
--- src/Makefile.orig Sat Nov 24 13:20:21 2001
+++ src/Makefile Sat Nov 24 13:20:34 2001
--- src/Makefile Sun Nov 25 07:37:30 2001
+++ src/Makefile Sun Dec 2 19:34:46 2001
@@ -1,6 +1,6 @@
#CC = gcc
-CFLAGS =-g -march=i586 -O2 -Wall `glib-config --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings #-Wshadow
-LDFLAGS = -g `glib-config --libs glib gthread`
+CFLAGS +=-g -Wall `${GLIB_CONFIG} --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings -I${LOCALBASE}/include ${PTHREAD_CFLAGS}
+CFLAGS += -g -Wall `${GLIB_CONFIG} --cflags glib gthread` -Wpointer-arith -Wcast-qual -Wwrite-strings -I${LOCALBASE}/include ${PTHREAD_CFLAGS}
+LDFLAGS += -g `${GLIB_CONFIG} --libs glib gthread` ${PTHREAD_LIBS}
CSRC = main.c action.c dc_com.c display.c key.c keyboard.c network.c typical_action.c dc_manage.c db.c he3.c gts.c user_manage.c md.c timed_out_string.c sema.c

View File

@ -1,69 +1,11 @@
--- src/db.c.orig Thu Nov 22 00:08:34 2001
+++ src/db.c Thu Nov 22 00:11:49 2001
@@ -30,6 +30,15 @@
--- src/db.c Mon Nov 26 16:28:32 2001
+++ src/db.c Sun Dec 2 19:34:12 2001
@@ -30,6 +30,8 @@
#include <netinet/in.h>
#include <glib.h>
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+#include "config.h"
+
#include "db.h"
#include "display.h"
#include "var.h"
@@ -711,6 +720,9 @@
/******************************************************************************************/
static void send_a_db_result(int output_sck, char *dest_nick, DB_ENTRY *de, struct sockaddr_in *dest_addr, char *md5sum)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
GString *str;
GString *adapted;
@@ -752,10 +764,38 @@
printf("dest_addr: %s, str: %s\n",dest_addr,str->str);
#endif
- if(dest_addr==NULL)
+ if(dest_addr==NULL) {
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
send(output_sck,str->str,str->len,MSG_NOSIGNAL);
- else
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ } else {
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
sendto(output_sck,str->str,str->len,MSG_NOSIGNAL,(void*)dest_addr, sizeof(struct sockaddr_in));
+
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ }
disp_msg(INFO_MSG,"send_search_result_line",str->str,NULL);

View File

@ -1,52 +1,11 @@
--- src/dc_com.c.orig Thu Nov 22 00:12:50 2001
+++ src/dc_com.c Thu Nov 22 00:15:55 2001
@@ -33,6 +33,15 @@
--- src/dc_com.c Sat Oct 20 03:46:54 2001
+++ src/dc_com.c Sun Dec 2 19:34:12 2001
@@ -28,6 +28,8 @@
#include <errno.h>
#include <glib.h>
+#include "config.h"
+
#include "dc_com.h"
#include "display.h"
#include "main.h"
#include "var.h"
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+
char last_cmd[5120]; /* contains the first string of the last send_dc_line call */
/* mainly used for debug features. */
time_t last_cmd_time;
@@ -50,6 +59,10 @@
/***********************************************************/
void send_dc_line(int sck,...)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+ ssize_t send_return;
+#endif
va_list ap;
char *t;
int have=0;
@@ -84,7 +97,21 @@
if((str->len)&&(cnx_in_progress==0))
{
- if(send(sck,str->str,str->len,MSG_NOSIGNAL)!=str->len)
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
+ send_return = send(sck,str->str,str->len, MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
+ if(send_return!=str->len)
{
/* abort network operation on this socket */
/* this will either generated a hub_disconnection message (main thread) */

View File

@ -1,5 +1,5 @@
--- src/dc_com.h.orig Wed Nov 21 22:15:21 2001
+++ src/dc_com.h Wed Nov 21 22:15:32 2001
--- src/dc_com.h Sat Oct 20 03:32:19 2001
+++ src/dc_com.h Sun Dec 2 19:34:12 2001
@@ -21,6 +21,8 @@
#ifndef __DC_COM_H__
#define __DC_COM_H__

View File

@ -1,264 +1,11 @@
--- src/dc_manage.c.orig Sat Nov 24 08:43:42 2001
+++ src/dc_manage.c Sat Nov 24 13:17:32 2001
@@ -35,6 +35,11 @@
--- src/dc_manage.c Sat Dec 1 08:45:25 2001
+++ src/dc_manage.c Sun Dec 2 19:34:12 2001
@@ -35,6 +35,8 @@
#include <fcntl.h>
#include <pthread.h>
+#if (defined(BSD) && (BSD >= 199103))
+#include <signal.h>
+#define MSG_NOSIGNAL 0
+#endif
+#include "config.h"
+
#include "display.h"
#include "action.h"
#include "macro.h"
@@ -189,6 +194,9 @@
/*************************/
static int send_file_data(int sck,char *filename, int start_pos, unsigned long file_len,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
unsigned long int i;
char buf[8192]; /* must be a multiple of 512 */
unsigned long int a=file_len-start_pos;
@@ -220,7 +228,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,sizeof(buf)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,buf,sizeof(buf),MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=sizeof(buf))
@@ -240,7 +261,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,buf,remain,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=remain)
@@ -259,6 +293,9 @@
/*************************/
static int send_array_data(int sck,GByteArray *ba,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
unsigned long int i;
unsigned long int nb;
int remain;
@@ -274,7 +311,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,BLOCK_SIZE/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,ba->data+cur_pos,BLOCK_SIZE,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=BLOCK_SIZE)
@@ -292,7 +342,20 @@
act->last_touch=time(NULL);
get_slices(bl_semid,(remain+511)/512); /* obtain upload authorization */
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,ba->data+cur_pos,remain,MSG_NOSIGNAL|MSG_WAITALL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if(res!=remain)
@@ -326,6 +389,9 @@
/**************************************************************************/
static int com_up_get_list_len_process(const char *cmd,WAIT_ACT *act,int sck,GString *input, char *xtra_param)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
GByteArray *cpy_data;
GString *out;
int res;
@@ -377,7 +443,20 @@
disp_msg(DEBUG_MSG,"reply",out->str,NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,out->str,out->len,MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
res=(res!=out->len);
g_string_free(out,TRUE);
if(res)
@@ -403,7 +482,20 @@
g_string_sprintfa(out,"%lu|",(unsigned long)100000+rand()%500000);
else
g_string_sprintfa(out,"%lu|",(unsigned long)cpy_data->len);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
res=send(sck,out->str,out->len,MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
res=(res!=out->len);
g_string_free(out,TRUE);
if(res)
@@ -674,6 +766,9 @@
/*****************************************************************/
static int copie_fd_to_file(int remote, FILE *local, unsigned long amount,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
while(amount!=0)
{
char buf[8192];
@@ -684,7 +779,20 @@
/* touch the action slot to avoid timeout */
act->last_touch=time(NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
ret=recv(remote,buf,nb,MSG_WAITALL|MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if((ret==-1)||(ret==0))
@@ -1019,6 +1127,9 @@
/*****************************************************************/
static int copie_fd_to_bytearray(int remote, GByteArray **ba, unsigned long amount,WAIT_ACT *act)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
int pos=0;
int ret;
unsigned long nb;
@@ -1032,12 +1143,25 @@
/* touch the action slot to avoid timeout */
act->last_touch=time(NULL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
#if 0
ret=recv(remote,(*ba)->data+pos,nb,MSG_WAITALL|MSG_NOSIGNAL);
#else
ret=recv(remote,(*ba)->data+pos,nb,MSG_NOSIGNAL);
printf("%d\n",ret);
#endif
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
act->last_touch=time(NULL);
if((ret==-1)||(ret==0))
@@ -2674,10 +2798,26 @@
/*******************************************************/
int manage_srch_port(int srch_sck, int sck)
{
+#if (defined(BSD) && (BSD >= 199103))
+ sigset_t sigset, sigoset;
+#endif
char buf[8192];
int ret;
+#if (defined(BSD) && (BSD >= 199103))
+ /* possible race condition since backup and restore
+ are not guaranteed to occur as a single operation */
+
+ /* backup sigmask and block SIGPIPE */
+ sigemptyset(&sigset);
+ sigaddset(&sigset,SIGPIPE);
+ (void) sigprocmask(SIG_BLOCK, &sigset, &sigoset);
+#endif
ret=recv(srch_sck,buf,sizeof(buf),MSG_NOSIGNAL);
+#if (defined(BSD) && (BSD >= 199103))
+ /* restore sigmask backup */
+ (void)sigprocmask(SIG_SETMASK, &sigoset, NULL);
+#endif
if(ret!=-1)
{
int i;

View File

@ -1,14 +1,16 @@
--- src/keyboard.c.orig Sat Nov 24 13:29:15 2001
+++ src/keyboard.c Sat Nov 24 13:43:51 2001
@@ -31,6 +31,7 @@
--- src/keyboard.c Sat Dec 1 08:53:15 2001
+++ src/keyboard.c Sun Dec 2 19:34:12 2001
@@ -31,6 +31,9 @@
#include <netdb.h>
#include <glib.h>
+#include "config.h"
+
+#if !(defined(BSD) && (BSD >= 199103))
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#else
@@ -42,6 +43,7 @@
@@ -42,6 +45,7 @@
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif

View File

@ -1,6 +1,6 @@
--- src/main.c.orig Sat Nov 24 13:22:57 2001
+++ src/main.c Sat Nov 24 13:25:24 2001
@@ -30,12 +30,23 @@
--- src/main.c Sat Dec 1 09:05:19 2001
+++ src/main.c Sun Dec 2 19:34:12 2001
@@ -30,12 +30,13 @@
#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/un.h>
@ -11,17 +11,7 @@
#include <glib.h>
#include <pthread.h>
+
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if (defined(BSD) && (BSD >= 199103))
+# include <sys/ipc.h>
+# include <sys/sem.h>
+#else
+/* For linux */
+# include <linux/sem.h> /* for the value of SEMVMX */
+#endif
+#include "config.h"
#include "var.h"
#include "display.h"

View File

@ -1,18 +1,17 @@
--- src/sema.c.orig Sat Nov 24 13:48:16 2001
+++ src/sema.c Sat Nov 24 14:53:39 2001
@@ -31,6 +31,11 @@
--- src/sema.c Sat Nov 24 08:29:56 2001
+++ src/sema.c Sun Dec 2 19:34:12 2001
@@ -29,8 +29,10 @@
#include <limits.h>
#include <pthread.h>
+#include "config.h"
#include "sema.h"
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#if !(defined(BSD) && (BSD >= 199103))
#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
/* union semun is defined by including <sys/sem.h> */
#else
@@ -42,6 +47,7 @@
@@ -42,6 +44,7 @@
struct seminfo *__buf; /* buffer for IPC_INFO */
};
#endif
@ -20,12 +19,3 @@
#ifndef IPC_ALLOC
#define IPC_ALLOC 0
@@ -201,7 +207,7 @@
pthread_attr_init (&thread_attr);
pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
- if(pthread_create(&thread_id,&thread_attr, (void*)sema_master,(void*)semid)!=0)
+ if(pthread_create(&thread_id,&thread_attr, sema_master,(void*)semid)!=0)
{
/* if the creation of the clock thread fails, release the master sema */
/* else nobody will try to create a new clock and all xfers will hang */