frontport SLE11 patches:
OBS-URL: https://build.opensuse.org/package/show/network:utilities/openslp?expand=0&rev=26
This commit is contained in:
parent
5cf338cef6
commit
4572ddb5d3
@ -1,3 +1,22 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 13 15:03:15 CET 2014 - mls@suse.de
|
||||
|
||||
- frontport SLE11 patches:
|
||||
* add hardMTU option to limit the datagram package size to
|
||||
1400 bytes [bnc#648384].
|
||||
patch: openslp.hardmtu.diff
|
||||
* fix double free in SLPDKnownDAAdd error case [bnc#667953]
|
||||
patch: openslp.knowndafree.diff
|
||||
* fix libslp socket handling, check if socket is still alive
|
||||
and fix socket close code [bnc#693756]
|
||||
patch: openslp.loopbacksocket.diff
|
||||
* make openslpd reconnect to DAs if they closed the connection
|
||||
[bnc#723385]
|
||||
patch: openslp.slpdreconnect.diff
|
||||
* fixup lifetime of registrations a bit so that they
|
||||
don't get removed too early [bnc#658972]
|
||||
patch: openslp.lifetime.diff
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 16 13:44:12 CEST 2013 - mls@suse.de
|
||||
|
||||
|
259
openslp.hardmtu.diff
Normal file
259
openslp.hardmtu.diff
Normal file
@ -0,0 +1,259 @@
|
||||
--- ./common/slp_property.c.orig 2011-01-18 11:03:59.000000000 +0000
|
||||
+++ ./common/slp_property.c 2011-01-18 13:05:43.000000000 +0000
|
||||
@@ -217,6 +217,7 @@ int SetDefaultValues()
|
||||
result |= SLPPropertySet("net.slp.isDABackup","false");
|
||||
result |= SLPPropertySet("net.slp.DABackupInterval","900");
|
||||
result |= SLPPropertySet("net.slp.DABackupLocalReg","false");
|
||||
+ result |= SLPPropertySet("net.slp.hardMTU","false");
|
||||
|
||||
return result;
|
||||
}
|
||||
--- ./etc/slp.conf.orig 2011-01-18 10:54:51.000000000 +0000
|
||||
+++ ./etc/slp.conf 2011-01-18 13:05:02.000000000 +0000
|
||||
@@ -156,6 +156,12 @@
|
||||
# A integer giving the network packet MTU in bytes. (Default is 1400)
|
||||
;net.slp.MTU = 1400
|
||||
|
||||
+# make sure that UDP packets really are smaller than the MTU. Normally
|
||||
+# openslp will truncate packets so that they are a bit bigger than
|
||||
+# the MTU, as a workaround for bugs in old openslp implementations.
|
||||
+# (Default is false)
|
||||
+;net.slp.hardMTU = false
|
||||
+
|
||||
# A list of IP address of network interfaces on which the DA/SA should listen
|
||||
# for slp requests. By default, slpd will use all interfaces.
|
||||
;net.slp.interfaces = 1.2.3.4,1.2.3.5,1.2.3.6
|
||||
--- ./slpd/slpd_incoming.c.orig 2011-01-18 13:12:40.000000000 +0000
|
||||
+++ ./slpd/slpd_incoming.c 2011-01-18 13:14:09.000000000 +0000
|
||||
@@ -94,6 +94,8 @@ void IncomingDatagramRead(SLPList* sockl
|
||||
truncate = SLP_MAX_DATAGRAM_SIZE;
|
||||
if (G_SlpdProperty.oversizedUDP)
|
||||
truncate = 0;
|
||||
+ if (G_SlpdProperty.hardMTU)
|
||||
+ truncate = SLP_MAX_DATAGRAM_SIZE - 28;
|
||||
switch (SLPDProcessMessage(&sock->peeraddr,
|
||||
sock->recvbuf,
|
||||
&(sock->sendbuf),
|
||||
--- ./slpd/slpd_process.c.orig 2011-01-18 11:49:46.000000000 +0000
|
||||
+++ ./slpd/slpd_process.c 2011-01-18 13:05:19.000000000 +0000
|
||||
@@ -313,6 +313,7 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
SLPUrlEntry* urlentry;
|
||||
SLPDDatabaseSrvRqstResult* db = 0;
|
||||
int size = 0;
|
||||
+ int truncated = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
/*--------------------------------------------------------------*/
|
||||
@@ -444,14 +445,18 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
{
|
||||
for (i=0;i<db->urlcount;i++)
|
||||
{
|
||||
+ int oldsize = size;
|
||||
/* check size limitation */
|
||||
if (truncate && size > truncate)
|
||||
+ {
|
||||
+ truncated = 1;
|
||||
break;
|
||||
+ }
|
||||
|
||||
/* urlentry is the url from the db result */
|
||||
urlentry = db->urlarray[i];
|
||||
|
||||
- if (urlentry->opaque == 0)
|
||||
+ if (urlentry->opaque == 0)
|
||||
{
|
||||
size += urlentry->urllen + 6; /* 1 byte for reserved */
|
||||
/* 2 bytes for lifetime */
|
||||
@@ -462,6 +467,12 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
{
|
||||
size += urlentry->opaquelen;
|
||||
}
|
||||
+ if (G_SlpdProperty.hardMTU && truncate && size > truncate)
|
||||
+ {
|
||||
+ size = oldsize;
|
||||
+ truncated = 1;
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -486,7 +497,7 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
ToUINT24(result->start + 2, size);
|
||||
/*flags*/
|
||||
ToUINT16(result->start + 5,
|
||||
- (size > SLP_MAX_DATAGRAM_SIZE ? SLP_FLAG_OVERFLOW : 0));
|
||||
+ (size > SLP_MAX_DATAGRAM_SIZE || truncated ? SLP_FLAG_OVERFLOW : 0));
|
||||
/*ext offset*/
|
||||
ToUINT24(result->start + 7,0);
|
||||
/*xid*/
|
||||
@@ -514,8 +525,12 @@ int ProcessSrvRqst(SLPMessage message,
|
||||
for (i=0;i<db->urlcount;i++)
|
||||
{
|
||||
/* check size limitation */
|
||||
- if (truncate && result->curpos - result->start > truncate)
|
||||
+ if (result->curpos - result->start >= size)
|
||||
+ {
|
||||
+ /* reached size limit due to truncation. fix up url count */
|
||||
+ ToUINT16(result->start + 14 + message->header.langtaglen + 2, i);
|
||||
break;
|
||||
+ }
|
||||
|
||||
/* urlentry is the url from the db result */
|
||||
urlentry = db->urlarray[i];
|
||||
@@ -818,11 +833,14 @@ int ProcessSrvAck(SLPMessage message,
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int ProcessAttrRqst(SLPMessage message,
|
||||
SLPBuffer* sendbuf,
|
||||
- int errorcode)
|
||||
+ int errorcode,
|
||||
+ int truncate)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
{
|
||||
SLPDDatabaseAttrRqstResult* db = 0;
|
||||
int size = 0;
|
||||
+ int truncated = 0;
|
||||
+ int attrlistlen = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
#ifdef ENABLE_SLPv2_SECURITY
|
||||
@@ -995,6 +1013,16 @@ int ProcessAttrRqst(SLPMessage message,
|
||||
size += opaqueauthlen;
|
||||
}
|
||||
#endif
|
||||
+
|
||||
+ /* truncate if needed */
|
||||
+ attrlistlen = db->attrlistlen;
|
||||
+ if (truncate && size > truncate && G_SlpdProperty.hardMTU)
|
||||
+ {
|
||||
+ attrlistlen = 0;
|
||||
+ opaqueauth = 0;
|
||||
+ size = message->header.langtaglen + 19; /* 14 bytes for header */
|
||||
+ truncated = 1;
|
||||
+ }
|
||||
}
|
||||
|
||||
/*-------------------*/
|
||||
@@ -1018,7 +1046,7 @@ int ProcessAttrRqst(SLPMessage message,
|
||||
ToUINT24(result->start + 2,size);
|
||||
/*flags*/
|
||||
ToUINT16(result->start + 5,
|
||||
- (size > SLP_MAX_DATAGRAM_SIZE ? SLP_FLAG_OVERFLOW : 0));
|
||||
+ (size > SLP_MAX_DATAGRAM_SIZE || truncated ? SLP_FLAG_OVERFLOW : 0));
|
||||
/*ext offset*/
|
||||
ToUINT24(result->start + 7,0);
|
||||
/*xid*/
|
||||
@@ -1040,13 +1068,13 @@ int ProcessAttrRqst(SLPMessage message,
|
||||
if (errorcode == 0)
|
||||
{
|
||||
/* attr-list len */
|
||||
- ToUINT16(result->curpos, db->attrlistlen);
|
||||
+ ToUINT16(result->curpos, attrlistlen);
|
||||
result->curpos = result->curpos + 2;
|
||||
- if (db->attrlistlen)
|
||||
+ if (attrlistlen)
|
||||
{
|
||||
- memcpy(result->curpos, db->attrlist, db->attrlistlen);
|
||||
+ memcpy(result->curpos, db->attrlist, attrlistlen);
|
||||
}
|
||||
- result->curpos = result->curpos + db->attrlistlen;
|
||||
+ result->curpos = result->curpos + attrlistlen;
|
||||
|
||||
/* authentication block */
|
||||
#ifdef ENABLE_SLPv2_SECURITY
|
||||
@@ -1157,10 +1185,13 @@ int ProcessDAAdvert(SLPMessage message,
|
||||
/*-------------------------------------------------------------------------*/
|
||||
int ProcessSrvTypeRqst(SLPMessage message,
|
||||
SLPBuffer* sendbuf,
|
||||
- int errorcode)
|
||||
+ int errorcode,
|
||||
+ int truncate)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
{
|
||||
int size = 0;
|
||||
+ int truncated = 0;
|
||||
+ int typelistlen = 0;
|
||||
SLPDDatabaseSrvTypeRqstResult* db = 0;
|
||||
SLPBuffer result = *sendbuf;
|
||||
|
||||
@@ -1230,6 +1261,15 @@ int ProcessSrvTypeRqst(SLPMessage messag
|
||||
if(errorcode == 0)
|
||||
{
|
||||
size += db->srvtypelistlen;
|
||||
+ typelistlen = db->srvtypelistlen;
|
||||
+
|
||||
+ /* truncate result if needed */
|
||||
+ if (truncate && size > truncate && G_SlpdProperty.hardMTU)
|
||||
+ {
|
||||
+ typelistlen = 0;
|
||||
+ size -= db->srvtypelistlen;
|
||||
+ truncated = 1;
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
@@ -1254,7 +1294,7 @@ int ProcessSrvTypeRqst(SLPMessage messag
|
||||
ToUINT24(result->start + 2,size);
|
||||
/*flags*/
|
||||
ToUINT16(result->start + 5,
|
||||
- (size > SLP_MAX_DATAGRAM_SIZE ? SLP_FLAG_OVERFLOW : 0));
|
||||
+ (size > SLP_MAX_DATAGRAM_SIZE || truncated ? SLP_FLAG_OVERFLOW : 0));
|
||||
/*ext offset*/
|
||||
ToUINT24(result->start + 7,0);
|
||||
/*xid*/
|
||||
@@ -1278,12 +1318,13 @@ int ProcessSrvTypeRqst(SLPMessage messag
|
||||
if (errorcode == 0)
|
||||
{
|
||||
/* length of srvtype-list */
|
||||
- ToUINT16(result->curpos, db->srvtypelistlen);
|
||||
+ ToUINT16(result->curpos, typelistlen);
|
||||
result->curpos += 2;
|
||||
- memcpy(result->curpos,
|
||||
- db->srvtypelist,
|
||||
- db->srvtypelistlen);
|
||||
- result->curpos += db->srvtypelistlen;
|
||||
+ if (typelistlen)
|
||||
+ memcpy(result->curpos,
|
||||
+ db->srvtypelist,
|
||||
+ typelistlen);
|
||||
+ result->curpos += typelistlen;
|
||||
}
|
||||
|
||||
|
||||
@@ -1413,7 +1454,7 @@ int SLPDProcessMessage(struct sockaddr_i
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_ATTRRQST:
|
||||
- errorcode = ProcessAttrRqst(message,sendbuf, errorcode);
|
||||
+ errorcode = ProcessAttrRqst(message,sendbuf, errorcode, truncate);
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_DAADVERT:
|
||||
@@ -1424,7 +1465,7 @@ int SLPDProcessMessage(struct sockaddr_i
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_SRVTYPERQST:
|
||||
- errorcode = ProcessSrvTypeRqst(message, sendbuf, errorcode);
|
||||
+ errorcode = ProcessSrvTypeRqst(message, sendbuf, errorcode, truncate);
|
||||
break;
|
||||
|
||||
case SLP_FUNCT_SAADVERT:
|
||||
--- ./slpd/slpd_property.c.orig 2011-01-18 11:02:36.000000000 +0000
|
||||
+++ ./slpd/slpd_property.c 2011-01-18 13:05:29.000000000 +0000
|
||||
@@ -237,6 +237,7 @@ int SLPDPropertyInit(const char* conffil
|
||||
G_SlpdProperty.isDABackup = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.isDABackup"));
|
||||
G_SlpdProperty.DABackupInterval = SLPPropertyAsInteger(SLPPropertyGet("net.slp.DABackupInterval"));
|
||||
G_SlpdProperty.DABackupLocalReg = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.DABackupLocalReg"));
|
||||
+ G_SlpdProperty.hardMTU = SLPPropertyAsBoolean(SLPPropertyGet("net.slp.hardMTU"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
--- ./slpd/slpd_property.h.orig 2011-01-18 11:02:09.000000000 +0000
|
||||
+++ ./slpd/slpd_property.h 2011-01-18 13:05:39.000000000 +0000
|
||||
@@ -100,6 +100,7 @@ typedef struct _SLPDProperty
|
||||
int isDABackup;
|
||||
int DABackupInterval;
|
||||
int DABackupLocalReg;
|
||||
+ int hardMTU;
|
||||
}SLPDProperty;
|
||||
|
||||
|
23
openslp.knowndafree.diff
Normal file
23
openslp.knowndafree.diff
Normal file
@ -0,0 +1,23 @@
|
||||
--- slpd/slpd_knownda.c.orig 2011-02-16 12:49:41.000000000 +0000
|
||||
+++ slpd/slpd_knownda.c 2011-02-16 12:53:02.000000000 +0000
|
||||
@@ -823,15 +823,15 @@ int SLPDKnownDAAdd(SLPMessage msg, SLPBu
|
||||
*/
|
||||
SLPDLogDAAdvertisement("Removed",entry);
|
||||
}
|
||||
+ /* If we are here, we need to cleanup the message descriptor and the */
|
||||
+ /* message buffer because they were not added to the database and not */
|
||||
+ /* cleaning them up would result in a memory leak */
|
||||
+ SLPMessageFree(msg);
|
||||
+ SLPBufferFree(buf);
|
||||
}
|
||||
|
||||
CLEANUP:
|
||||
- /* If we are here, we need to cleanup the message descriptor and the */
|
||||
- /* message buffer because they were not added to the database and not */
|
||||
- /* cleaning them up would result in a memory leak */
|
||||
/* We also need to make sure the Database handle is closed. */
|
||||
- SLPMessageFree(msg);
|
||||
- SLPBufferFree(buf);
|
||||
if (dh) SLPDatabaseClose(dh);
|
||||
|
||||
return result;
|
18
openslp.lifetime.diff
Normal file
18
openslp.lifetime.diff
Normal file
@ -0,0 +1,18 @@
|
||||
--- slpd/slpd_database.c.orig 2011-11-25 16:50:29.000000000 +0000
|
||||
+++ slpd/slpd_database.c 2011-11-25 16:55:32.000000000 +0000
|
||||
@@ -185,6 +185,15 @@ int SLPDDatabaseReg(SLPMessage msg, SLPB
|
||||
return SLP_ERROR_INVALID_REGISTRATION;
|
||||
}
|
||||
|
||||
+ /* fixup the lifetime a bit */
|
||||
+ if ( reg->urlentry.lifetime > 0 && reg->urlentry.lifetime < SLP_LIFETIME_MAXIMUM )
|
||||
+ {
|
||||
+ if (reg->urlentry.lifetime >= SLP_LIFETIME_MAXIMUM - SLPD_AGE_INTERVAL)
|
||||
+ reg->urlentry.lifetime = SLP_LIFETIME_MAXIMUM - 1;
|
||||
+ else
|
||||
+ reg->urlentry.lifetime += SLPD_AGE_INTERVAL;
|
||||
+ }
|
||||
+
|
||||
dh = SLPDatabaseOpen(&G_SlpdDatabase.database);
|
||||
if ( dh )
|
||||
{
|
117
openslp.loopbacksocket.diff
Normal file
117
openslp.loopbacksocket.diff
Normal file
@ -0,0 +1,117 @@
|
||||
--- libslp/libslp_network.c.orig 2011-06-03 17:43:59.000000000 +0000
|
||||
+++ libslp/libslp_network.c 2011-06-07 15:19:11.000000000 +0000
|
||||
@@ -98,6 +98,36 @@ int NetworkConnectToSlpd(struct sockaddr
|
||||
return result;
|
||||
}
|
||||
|
||||
+/* check if the socket is still alive, the server may have closed it
|
||||
+ * in the meantime */
|
||||
+static int
|
||||
+NetworkCheckConnection(int fd)
|
||||
+{
|
||||
+ int r;
|
||||
+#ifdef HAVE_POLL
|
||||
+ struct pollfd readfd;
|
||||
+#else
|
||||
+ fd_set readfd;
|
||||
+ struct timeval tv;
|
||||
+#endif
|
||||
+
|
||||
+#ifdef HAVE_POLL
|
||||
+ readfd.fd = fd;
|
||||
+ readfd.events = POLLIN;
|
||||
+ while ((r = poll(&readfd, 1, 0)) == -1 && errno == EINTR)
|
||||
+ ;
|
||||
+#else
|
||||
+ FD_ZERO(&readfd);
|
||||
+ FD_SET(fd, &readfd);
|
||||
+ tv.tv_sec = 0;
|
||||
+ tv.tv_usec = 0;
|
||||
+ while ((r = select(fd + 1, &readfd, 0, 0, &tv)) == -1 && errno == EINTR)
|
||||
+ ;
|
||||
+#endif
|
||||
+ /* r == 0 means timeout, everything else is an error */
|
||||
+ return r == 0 ? SLP_OK : SLP_NETWORK_ERROR;
|
||||
+}
|
||||
+
|
||||
/*=========================================================================*/
|
||||
void NetworkDisconnectDA(PSLPHandleInfo handle)
|
||||
/* Called after DA fails to respond */
|
||||
@@ -105,7 +135,7 @@ void NetworkDisconnectDA(PSLPHandleInfo
|
||||
/* handle (IN) a handle previously passed to NetworkConnectToDA() */
|
||||
/*=========================================================================*/
|
||||
{
|
||||
- if(handle->dasock)
|
||||
+ if(handle->dasock >= 0)
|
||||
{
|
||||
close(handle->dasock);
|
||||
handle->dasock = -1;
|
||||
@@ -123,7 +153,7 @@ void NetworkDisconnectSA(PSLPHandleInfo
|
||||
/* handle (IN) a handle previously passed to NetworkConnectToSA() */
|
||||
/*=========================================================================*/
|
||||
{
|
||||
- if(handle->sasock)
|
||||
+ if(handle->sasock >= 0)
|
||||
{
|
||||
close(handle->sasock);
|
||||
handle->sasock = -1;
|
||||
@@ -162,6 +192,11 @@ int NetworkConnectToDA(PSLPHandleInfo ha
|
||||
scopelist) == 0)
|
||||
{
|
||||
memcpy(peeraddr,&(handle->daaddr),sizeof(struct sockaddr_in));
|
||||
+ if (NetworkCheckConnection(handle->dasock) != SLP_OK)
|
||||
+ {
|
||||
+ close(handle->dasock);
|
||||
+ handle->dasock = -1;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,8 +204,11 @@ int NetworkConnectToDA(PSLPHandleInfo ha
|
||||
if(handle->dasock >= 0)
|
||||
{
|
||||
close(handle->dasock);
|
||||
+ handle->dasock = -1;
|
||||
}
|
||||
-
|
||||
+ }
|
||||
+ if (handle->dasock < 0)
|
||||
+ {
|
||||
/* Attempt to connect to DA that does support the scope */
|
||||
handle->dasock = KnownDAConnect(handle,
|
||||
scopelistlen,
|
||||
@@ -220,6 +258,11 @@ int NetworkConnectToSA(PSLPHandleInfo ha
|
||||
scopelist) == 0)
|
||||
{
|
||||
memcpy(peeraddr,&(handle->saaddr),sizeof(struct sockaddr_in));
|
||||
+ if (NetworkCheckConnection(handle->sasock) != SLP_OK)
|
||||
+ {
|
||||
+ close(handle->sasock);
|
||||
+ handle->sasock = -1;
|
||||
+ }
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -227,7 +270,11 @@ int NetworkConnectToSA(PSLPHandleInfo ha
|
||||
if(handle->sasock >= 0)
|
||||
{
|
||||
close(handle->sasock);
|
||||
+ handle->sasock = -1;
|
||||
}
|
||||
+ }
|
||||
+ if (handle->sasock < 0)
|
||||
+ {
|
||||
|
||||
/*-----------------------------------------*/
|
||||
/* Attempt to connect to slpd via loopback */
|
||||
--- slpd/slpd.h.orig 2011-06-07 08:31:44.000000000 +0000
|
||||
+++ slpd/slpd.h 2011-06-07 08:32:14.000000000 +0000
|
||||
@@ -67,7 +67,7 @@
|
||||
/* to complete an outgoing */
|
||||
/* transaction */
|
||||
|
||||
-#define SLPD_MAX_SOCKETS 128 /* maximum number of sockets */
|
||||
+#define SLPD_MAX_SOCKETS 256 /* maximum number of sockets */
|
||||
|
||||
#define SLPD_COMFORT_SOCKETS 64 /* a "comfortable" number of */
|
||||
/* of sockets. Exceeding this */
|
96
openslp.slpdreconnect.diff
Normal file
96
openslp.slpdreconnect.diff
Normal file
@ -0,0 +1,96 @@
|
||||
--- ./slpd/slpd_outgoing.c.orig 2011-10-20 15:01:42.000000000 +0000
|
||||
+++ ./slpd/slpd_outgoing.c 2011-10-20 15:47:07.000000000 +0000
|
||||
@@ -127,6 +127,8 @@ void OutgoingStreamReconnect(SLPList* so
|
||||
/* We only allow SLPD_CONFIG_MAX_RECONN reconnection retries */
|
||||
/* before we stop */
|
||||
/*----------------------------------------------------------------*/
|
||||
+ if (sock->reconns == -1)
|
||||
+ sock->reconns = 0;
|
||||
sock->reconns += 1;
|
||||
if ( sock->reconns > SLPD_CONFIG_MAX_RECONN )
|
||||
{
|
||||
@@ -237,9 +239,16 @@ void OutgoingStreamRead(SLPList* socklis
|
||||
}
|
||||
}
|
||||
else
|
||||
- {
|
||||
- sock->state = SOCKET_CLOSE;
|
||||
- }
|
||||
+ {
|
||||
+ /* An EOF occured. This could mean that the other side closed
|
||||
+ * the connection due to the idle timeout. If we finished some
|
||||
+ * requests try a reconnect, otherwise simply drop the connection
|
||||
+ */
|
||||
+ if (sock->reconns == -1)
|
||||
+ OutgoingStreamReconnect(socklist,sock);
|
||||
+ else
|
||||
+ sock->state = SOCKET_CLOSE;
|
||||
+ }
|
||||
}
|
||||
|
||||
if ( sock->state == STREAM_READ )
|
||||
@@ -280,9 +289,11 @@ void OutgoingStreamRead(SLPList* socklis
|
||||
sock->sendbuf = NULL;
|
||||
sock->state = STREAM_WRITE_FIRST;
|
||||
/* clear the reconnection count since we actually
|
||||
- * transmitted a successful message exchange
|
||||
+ * transmitted a successful message exchange. We
|
||||
+ * use -1 to indicate that the socket had at
|
||||
+ * least one successful communication.
|
||||
*/
|
||||
- sock->reconns = 0;
|
||||
+ sock->reconns = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -303,6 +314,35 @@ void OutgoingStreamRead(SLPList* socklis
|
||||
}
|
||||
}
|
||||
|
||||
+/* check if the socket is still alive, the server may have closed it
|
||||
+ * in the meantime */
|
||||
+static int
|
||||
+NetworkCheckConnection(int fd)
|
||||
+{
|
||||
+ int r;
|
||||
+#ifdef HAVE_POLL
|
||||
+ struct pollfd readfd;
|
||||
+#else
|
||||
+ fd_set readfd;
|
||||
+ struct timeval tv;
|
||||
+#endif
|
||||
+
|
||||
+#ifdef HAVE_POLL
|
||||
+ readfd.fd = fd;
|
||||
+ readfd.events = POLLIN;
|
||||
+ while ((r = poll(&readfd, 1, 0)) == -1 && errno == EINTR)
|
||||
+ ;
|
||||
+#else
|
||||
+ FD_ZERO(&readfd);
|
||||
+ FD_SET(fd, &readfd);
|
||||
+ tv.tv_sec = 0;
|
||||
+ tv.tv_usec = 0;
|
||||
+ while ((r = select(fd + 1, &readfd, 0, 0, &tv)) == -1 && errno == EINTR)
|
||||
+ ;
|
||||
+#endif
|
||||
+ /* r == 0 means timeout, everything else is an error */
|
||||
+ return r == 0 ? 0 : -1;
|
||||
+}
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
void OutgoingStreamWrite(SLPList* socklist, SLPDSocket* sock)
|
||||
@@ -334,6 +374,14 @@ void OutgoingStreamWrite(SLPList* sockli
|
||||
/* make sure that the start and curpos pointers are the same */
|
||||
sock->sendbuf->curpos = sock->sendbuf->start;
|
||||
sock->state = STREAM_WRITE;
|
||||
+
|
||||
+ /* test the socket if it was already used */
|
||||
+ if (sock->reconns == -1 && sock->age > 10) {
|
||||
+ if (NetworkCheckConnection(sock->fd) != 0) {
|
||||
+ OutgoingStreamReconnect(socklist,sock);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
if ( sock->sendbuf->end - sock->sendbuf->curpos > 0 )
|
14
openslp.spec
14
openslp.spec
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package openslp
|
||||
#
|
||||
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -72,6 +72,11 @@ Patch22: openslp.parseext.diff
|
||||
Patch23: openslp-1.2.0-visibility.patch
|
||||
Patch24: openslp-1.2.0-daemon.diff
|
||||
Patch25: openslp-ocloexec.patch
|
||||
Patch26: openslp.hardmtu.diff
|
||||
Patch27: openslp.knowndafree.diff
|
||||
Patch28: openslp.loopbacksocket.diff
|
||||
Patch29: openslp.slpdreconnect.diff
|
||||
Patch30: openslp.lifetime.diff
|
||||
|
||||
%description
|
||||
Service Location Protocol is an IETF standards track protocol that
|
||||
@ -151,7 +156,12 @@ such applications.
|
||||
%patch22
|
||||
%patch23
|
||||
%patch24 -p1
|
||||
%patch25
|
||||
%patch25
|
||||
%patch26
|
||||
%patch27
|
||||
%patch28
|
||||
%patch29
|
||||
%patch30
|
||||
|
||||
%build
|
||||
autoreconf -fiv
|
||||
|
Loading…
x
Reference in New Issue
Block a user