summaryrefslogtreecommitdiff
path: root/ftp/prozilla
diff options
context:
space:
mode:
authorPav Lucistnik <pav@FreeBSD.org>2004-02-07 19:55:21 +0000
committerPav Lucistnik <pav@FreeBSD.org>2004-02-07 19:55:21 +0000
commitbcd2c14358c673fbdd22d45240c20c6dc7d2d1e0 (patch)
tree719ba76c7ac93f5819edb3f3b577e5963683505d /ftp/prozilla
parentTry to mount linproc in post-install. (diff)
- Workaround lack of reentrant gethostbyname()
PR: ports/60740 Submitted by: maintainer
Notes
Notes: svn path=/head/; revision=100279
Diffstat (limited to 'ftp/prozilla')
-rw-r--r--ftp/prozilla/Makefile2
-rw-r--r--ftp/prozilla/files/patch-connect.c134
2 files changed, 119 insertions, 17 deletions
diff --git a/ftp/prozilla/Makefile b/ftp/prozilla/Makefile
index 3fd96419b8b3..9cd6a876f2ee 100644
--- a/ftp/prozilla/Makefile
+++ b/ftp/prozilla/Makefile
@@ -7,7 +7,7 @@
PORTNAME= prozilla
PORTVERSION= 1.3.6
-PORTREVISION= 2
+PORTREVISION= 3
CATEGORIES= ftp
MASTER_SITES= http://prozilla.genesys.ro/downloads/prozilla/tarballs/
diff --git a/ftp/prozilla/files/patch-connect.c b/ftp/prozilla/files/patch-connect.c
index 3c9589aafc3e..71c1d863a39f 100644
--- a/ftp/prozilla/files/patch-connect.c
+++ b/ftp/prozilla/files/patch-connect.c
@@ -1,6 +1,10 @@
---- src/connect.c.orig Fri Aug 17 20:38:25 2001
-+++ src/connect.c Sat Jan 25 19:38:06 2003
-@@ -27,6 +27,7 @@
+--- src/connect.c.ori Fri Aug 17 20:38:25 2001
++++ src/connect.c Sat Feb 7 02:11:10 2004
+@@ -24,9 +24,11 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <unistd.h>
++#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <netdb.h>
@@ -8,22 +12,120 @@
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netdb.h>
-@@ -341,6 +342,8 @@
- struct hostent *hp;
- int herr,res;
+@@ -42,51 +44,58 @@
+ #include "runtime.h"
+ #include "debug.h"
-+#ifndef __FreeBSD__
++static pthread_mutex_t __thread_safe_lock = PTHREAD_MUTEX_INITIALIZER;
+
- if (*hstbuflen == 0)
+ uerr_t connect_to_server(int *sock, char *name, int port, int timeout)
+ {
+ unsigned int portnum;
++ char szPort[10];
+ int status;
+- struct sockaddr_in server;
+- struct hostent *hp, hostbuf;
+ extern int h_errno;
+ /* int opt; */
+ int noblock, flags;
+
+- char *tmphstbuf;
+- size_t hstbuflen = 2048;
+- tmphstbuf = kmalloc(hstbuflen);
++ struct addrinfo hints, *res=NULL;
++ struct addrinfo *res0=NULL;
++ int error;
++
++ memset(&hints, 0, sizeof(hints));
++ memset(szPort, 0, sizeof(szPort));
++ sprintf(szPort, "%d", port);
++ hints.ai_family = AF_INET;
++ hints.ai_socktype = SOCK_STREAM;
+
+ assert(name != NULL);
+
+- portnum = port;
+- memset((void *) &server, 0, sizeof(server));
+-
+ message("Resolving %s", name);
+
+- hp=k_gethostname (name,&hostbuf,&tmphstbuf,&hstbuflen);
+-
+- if (hp == NULL)
+- {
+- message("Failed to resolve %s", name);
+- return HOSTERR;
+- }
++ pthread_mutex_lock(&__thread_safe_lock);
+
+- message("Resolved %s !", name);
+-
+-
+- memcpy((void *) &server.sin_addr, hp->h_addr, hp->h_length);
+- server.sin_family = hp->h_addrtype;
+- server.sin_port = htons(portnum);
++ error = getaddrinfo(name, szPort, &hints, &res);
++ if (error) {
++ message("Failed to resolve %s", name);
++ pthread_mutex_unlock(&__thread_safe_lock);
++ freeaddrinfo(res);
++ return HOSTERR;
++ }
++
++ message("Resolved %s !", name);
++
++ res0 = (struct addrinfo *) malloc(sizeof(struct addrinfo));
++ memcpy(res0, res, sizeof(struct addrinfo));
++ freeaddrinfo(res);
++ pthread_mutex_unlock(&__thread_safe_lock);
+
+ /*
+ * create socket
+ */
+- if ((*sock = socket(AF_INET, SOCK_STREAM, 0)) < 1)
++ if ((*sock = socket(res0->ai_family, res0->ai_socktype, 0)) < 1)
{
- *hstbuflen = 2048;
-@@ -364,5 +367,9 @@
+ message("unable to create socket\n");
+- free(tmphstbuf);
++ free(res0);
+ return CONSOCKERR;
+ }
++
+ /*Experimental */
+ flags = fcntl(*sock, F_GETFL, 0);
+ if (flags != -1)
+@@ -96,8 +105,7 @@
+
+ message("Connecting to server.......");
+
+-
+- status = connect(*sock, (struct sockaddr *) &server, sizeof(server));
++ status = connect(*sock, res0->ai_addr, res0->ai_addrlen);
+
+ if (status == -1 && noblock != -1 && errno == EINPROGRESS)
+ {
+@@ -135,11 +143,11 @@
+
+ if (errno == ECONNREFUSED)
+ {
+- free(tmphstbuf);
++ free(res0);
+ return CONREFUSED;
+ } else
+ {
+- free(tmphstbuf);
++ free(res0);
+ return CONERROR;
}
- if (res)
- return NULL;
-+#else
-+ hp = gethostbyname(host);
-+#endif
+ } else
+@@ -156,8 +164,9 @@
+ /* setsockopt(*sock, SOL_SOCKET, SO_KEEPALIVE,
+ * (char *) &opt, (int) sizeof(opt));
+ */
+
- return hp;
+ message("Connect OK!");
+- free(tmphstbuf);
++ free(res0);
+ return NOCONERROR;
}
+