summaryrefslogtreecommitdiff
path: root/net/dctc/files/patch-src:db.c
diff options
context:
space:
mode:
authorMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2001-11-22 04:32:47 +0000
committerMario Sergio Fujikawa Ferreira <lioux@FreeBSD.org>2001-11-22 04:32:47 +0000
commitbc737cecdd7ad5ff3befcdfd212cb0b75e053b39 (patch)
treefe6f1621519189af72f850d91026b25f938553e1 /net/dctc/files/patch-src:db.c
parentAllow for slave ports to set different categories. (diff)
o New port dctc version 0.59: A DirectConnect (www.neo-modus.com)
text client for file sharing o Renamed hublist to dc_hublist; former was too generic o FreeBSD's send(2) (in fact, all *BSD) does not support MSG_NOSIGMASK or any similar feature. Therefore, tried to mimick it with signal masking. However, this introduces a possible race condition which, fortunaly, is not triggered by this application since it is not concurrent. Reviewed by: Anders Nor Berle <debolaz@debolaz.com>
Diffstat (limited to '')
-rw-r--r--net/dctc/files/patch-src:db.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/net/dctc/files/patch-src:db.c b/net/dctc/files/patch-src:db.c
new file mode 100644
index 000000000000..74abd7eca69b
--- /dev/null
+++ b/net/dctc/files/patch-src:db.c
@@ -0,0 +1,69 @@
+--- 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 @@
+ #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 "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);
+