Re: port limitation to int16
John Schultz <[email protected]> Thu, 8 Aug 2013 10:36:22 -0400
| Newsgroups | gmane.network.spread.user |
|---|---|
| Message-ID | <[email protected]> |
Try this patch out (on 4.3) to see if it fixes your issue: Cheers! ----- John Lane Schultz Spread Concepts LLC Cell: 443 838 2200 On Aug 8, 2013, at 9:41 AM, Johannes Wienke wrote: Hi, On 07.08.13 16:04 schrieb John Schultz: > I see it. It looks like that limitation was removed with 4.3.0. > > I think you can safely remove that check from your version or upgrade to 4.3. I just tried this with version 4.3 with mixed results. If I use e.g. 48000@localhost in the SP_connect call, the connection succeeds. However, if I try to use a local socket by providing only the port number connection does not work. Attached is a test program which demonstrates this problem. The connection problems in the case of socket communication are actually caused by the daemon itself. Looking at the output at start I can see: Conf_load_conf_file: My name: localhost, id: 127.0.0.1, port: -17536 Membership id is ( 2130706433, 1375968222) -------------------- Configuration at localhost is: Num Segments 1 1 127.0.0.255 -17536 localhost 127.0.0.1 ==================== Notice the negative port numbers. There is an integer overflow in the daemon and this does not only exist in the printing. Actually the socket file in /tmp is really called -17536. The client API doesn't seem to have this overflow and tries to correctly find a file with name 48000. Strangely, the TCP listen port is constructed without this overflow and the daemon correctly listens on 48000: languitar@miles:~$ lsof -i tcp:48000 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME spread 72864 languitar 6u IPv4 0x665a353ce83db745 0t0 TCP *:nimcontroller (LISTEN) Kind regards, Johannes <main.cpp><spread.conf>_______________________________________________ Spread-users mailing list [email protected] http://lists.spread.org/mailman/listinfo/spread-users _______________________________________________ Spread-users mailing list [email protected] http://lists.spread.org/mailman/listinfo/spread-users
daemon_port.patch
(application/octet-stream, 1.8 KB)
Index: configuration.c
===================================================================
--- configuration.c (revision 579)
+++ configuration.c (revision 584)
@@ -486,7 +486,7 @@
}
Conf_id_to_str( My.id, ip );
- Alarm( CONF_SYS, "Conf_load_conf_file: My name: %s, id: %s, port: %hd\n",
+ Alarm( CONF_SYS, "Conf_load_conf_file: My name: %s, id: %s, port: %hu\n",
My.name, ip, My.port );
return;
@@ -757,7 +757,7 @@
for ( s=0; s < config->num_segments; s++ )
{
Conf_id_to_str( config->segments[s].bcast_address, ip );
- Alarm( PRINT, "\t%d\t%-16s %hd\n",
+ Alarm( PRINT, "\t%d\t%-16s %hu\n",
config->segments[s].num_procs, ip,
config->segments[s].port );
for( p=0; p < config->segments[s].num_procs; p++)
Index: configuration.h
===================================================================
--- configuration.h (revision 579)
+++ configuration.h (revision 584)
@@ -57,12 +57,12 @@
struct spread_if_info {
int32u ip;
- int16 port;
+ int16u port;
int16 type;
};
typedef struct dummy_proc{
char name[MAX_PROC_NAME];
- int16 port;
+ int16u port;
int16 seg_index;
int16 index_in_seg;
int32u id;
@@ -72,7 +72,7 @@
typedef struct dummy_segment{
int32 bcast_address;
- int16 port;
+ int16u port;
int num_procs;
proc *procs[MAX_PROCS_SEGMENT];
} segment;
Index: session.c
===================================================================
--- session.c (revision 579)
+++ session.c (revision 584)
@@ -408,7 +408,7 @@
Alarm( EXIT, "Sess_init: UNIX sock error\n" );
unix_addr.sun_family = AF_UNIX;
- snprintf( name, sizeof(name), "%s/%d", SP_UNIX_SOCKET, My.port );
+ snprintf( name, sizeof(name), "%s/%hu", SP_UNIX_SOCKET, My.port );
strcpy( unix_addr.sun_path, name );
unlink( name );