[torqueusers] Torque reject error
Corey Hirschman
corey at rentec.com
Tue Nov 9 09:29:54 MST 2004
Here is a patch that eliminates the connection problems to the scheduler and moms while still allowing only priviledged ports 512-1024.
Corey
-------------- next part --------------
--- net_client.c.orig 2004-11-08 13:38:55.000000000 -0500
+++ net_client.c 2004-11-08 13:39:58.000000000 -0500
@@ -149,6 +149,7 @@
int sock;
unsigned short tryport;
int flags;
+ int one = 1;
local.sin_family = AF_INET;
local.sin_addr.s_addr = 0;
@@ -167,13 +168,18 @@
flags |= O_NONBLOCK;
fcntl(sock, F_SETFL, flags);
+
/* If local privilege port requested, bind to one */
/* Must be root privileged to do this */
if (local_port) {
+
+ setsockopt( sock, SOL_SOCKET, SO_REUSEADDR,
+ (const char*)&one, sizeof(one));
+
tryport = IPPORT_RESERVED - 1;
local.sin_port = htons(tryport);
-
+ retry:
while (bind(sock,(struct sockaddr *)&local,sizeof(local)) < 0) {
if ((errno != EADDRINUSE) &&
(errno != EADDRNOTAVAIL)) {
@@ -194,8 +200,13 @@
remote.sin_family = AF_INET;
if (connect(sock, (struct sockaddr *)&remote, sizeof(remote)) < 0)
switch (errno) {
+ case EADDRINUSE:
+ if( local_port ) {
+ --tryport;
+ goto retry;
+ }
+ /* fallthrough */
case EINTR:
- case EADDRINUSE:
case ETIMEDOUT:
case EINPROGRESS:
if (await_connect(5, sock) == 0)
More information about the torqueusers
mailing list