components/rsyslog/patches/tcp-restart.patch
branchs11-update
changeset 2853 f549a6950e55
child 1673 f4a923835a61
child 2924 894dcec4ac14
equal deleted inserted replaced
2852:3efbc4884df3 2853:f549a6950e55
       
     1 # This patch is to fix:
       
     2 # 16134419 rsyslogd forwarding over TCP does not detect server restart
       
     3 # which was fixed in upstream version 6.4.1; this patch is a minor variant
       
     4 # on the upstream patch, adapted for 6.2.0 .  This can go away once we
       
     5 # upgrade to 6.4.1 or later.
       
     6 --- rsyslog/runtime/netstrm.c.orig	2012-01-09 06:05:45.000000000 -0800
       
     7 +++ rsyslog/runtime/netstrm.c	2013-12-02 09:14:19.766000221 -0800
       
     8 @@ -250,7 +250,7 @@
       
     9  
       
    10  
       
    11  /* check connection - slim wrapper for NSD driver function */
       
    12 -static void
       
    13 +static rsRetVal
       
    14  CheckConnection(netstrm_t *pThis)
       
    15  {
       
    16  	ISOBJ_TYPE_assert(pThis, netstrm);
       
    17 --- rsyslog/runtime/netstrm.h~	2011-12-01 02:26:19.000000000 -0800
       
    18 +++ rsyslog/runtime/netstrm.h	2013-12-02 09:30:45.155766988 -0800
       
    19 @@ -53,7 +53,7 @@
       
    20  	rsRetVal (*SetDrvrMode)(netstrm_t *pThis, int iMode);
       
    21  	rsRetVal (*SetDrvrAuthMode)(netstrm_t *pThis, uchar*);
       
    22  	rsRetVal (*SetDrvrPermPeers)(netstrm_t *pThis, permittedPeers_t*);
       
    23 -	void     (*CheckConnection)(netstrm_t *pThis);	/* This is a trick mostly for plain tcp syslog */
       
    24 +	rsRetVal (*CheckConnection)(netstrm_t *pThis);	/* This is a trick mostly for plain tcp syslog */
       
    25  	/* the GetSock() below is a hack to make imgssapi work. In the long term,
       
    26  	 * we should migrate imgssapi to a stream driver, which will relieve us of
       
    27  	 * this problem. Please note that nobody else should use GetSock(). Using it 
       
    28 @@ -72,9 +72,10 @@
       
    29  	/* v4 */
       
    30  	rsRetVal (*EnableKeepAlive)(netstrm_t *pThis);
       
    31  ENDinterface(netstrm)
       
    32 -#define netstrmCURR_IF_VERSION 4 /* increment whenever you change the interface structure! */
       
    33 +#define netstrmCURR_IF_VERSION 5 /* increment whenever you change the interface structure! */
       
    34  /* interface version 3 added GetRemAddr()
       
    35   * interface version 4 added EnableKeepAlive() -- rgerhards, 2009-06-02
       
    36 + * interface version 5 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06
       
    37   * */
       
    38  
       
    39  /* prototypes */
       
    40 --- rsyslog/runtime/nsd.h.orig	2012-01-09 06:05:45.000000000 -0800
       
    41 +++ rsyslog/runtime/nsd.h	2013-12-02 09:21:26.146155301 -0800
       
    42 @@ -65,7 +65,7 @@
       
    43  	rsRetVal (*SetMode)(nsd_t *pThis, int mode); /* sets a driver specific mode - see driver doc for details */
       
    44  	rsRetVal (*SetAuthMode)(nsd_t *pThis, uchar*); /* sets a driver specific mode - see driver doc for details */
       
    45  	rsRetVal (*SetPermPeers)(nsd_t *pThis, permittedPeers_t*); /* sets driver permitted peers for auth needs */
       
    46 -	void     (*CheckConnection)(nsd_t *pThis);	/* This is a trick mostly for plain tcp syslog */
       
    47 +	rsRetVal (*CheckConnection)(nsd_t *pThis);	/* This is a trick mostly for plain tcp syslog */
       
    48  	rsRetVal (*GetSock)(nsd_t *pThis, int *pSock);
       
    49  	rsRetVal (*SetSock)(nsd_t *pThis, int sock);
       
    50  	/* GetSock() and SetSock() return an error if the driver does not use plain
       
    51 @@ -82,9 +82,10 @@
       
    52  	/* v5 */
       
    53  	rsRetVal (*EnableKeepAlive)(nsd_t *pThis);
       
    54  ENDinterface(nsd)
       
    55 -#define nsdCURR_IF_VERSION 5 /* increment whenever you change the interface structure! */
       
    56 +#define nsdCURR_IF_VERSION 6 /* increment whenever you change the interface structure! */
       
    57  /* interface version 4 added GetRemAddr()
       
    58   * interface version 5 added EnableKeepAlive() -- rgerhards, 2009-06-02
       
    59 + * interface version 6 changed return of CheckConnection from void to rsRetVal -- alorbach, 2012-09-06
       
    60   */
       
    61  
       
    62  /* interface  for the select call */
       
    63 --- rsyslog/runtime/nsd_gtls.c~	2012-01-09 06:05:45.000000000 -0800
       
    64 +++ rsyslog/runtime/nsd_gtls.c	2013-12-02 10:14:55.324156585 -0800
       
    65 @@ -1310,13 +1310,16 @@
       
    66   * This is a dummy here. For details, check function common in ptcp driver.
       
    67   * rgerhards, 2008-06-09
       
    68   */
       
    69 -static void
       
    70 +static rsRetVal
       
    71  CheckConnection(nsd_t __attribute__((unused)) *pNsd)
       
    72  {
       
    73 +	DEFiRet;
       
    74  	nsd_gtls_t *pThis = (nsd_gtls_t*) pNsd;
       
    75  	ISOBJ_TYPE_assert(pThis, nsd_gtls);
       
    76  
       
    77 -	nsd_ptcp.CheckConnection(pThis->pTcp);
       
    78 +	CHKiRet(nsd_ptcp.CheckConnection(pThis->pTcp));
       
    79 +finalize_it:
       
    80 +	RETiRet;
       
    81  }
       
    82  
       
    83  
       
    84 --- rsyslog/runtime/nsd_ptcp.c~	2012-01-09 06:05:17.000000000 -0800
       
    85 +++ rsyslog/runtime/nsd_ptcp.c	2013-12-02 10:13:48.561929979 -0800
       
    86 @@ -726,9 +726,10 @@
       
    87   * http://blog.gerhards.net/2008/06/getting-bit-more-reliability-from-plain.html
       
    88   * rgerhards, 2008-06-09
       
    89   */
       
    90 -static void
       
    91 +static rsRetVal
       
    92  CheckConnection(nsd_t *pNsd)
       
    93  {
       
    94 +	DEFiRet;
       
    95  	int rc;
       
    96  	char msgbuf[1]; /* dummy */
       
    97  	nsd_ptcp_t *pThis = (nsd_ptcp_t*) pNsd;
       
    98 @@ -741,7 +742,10 @@
       
    99  		 * need to close our side, too.
       
   100  		 */
       
   101  		sockClose(&pThis->sock);
       
   102 +		ABORT_FINALIZE(RS_RET_IO_ERROR);
       
   103  	}
       
   104 +finalize_it:
       
   105 +	RETiRet;
       
   106  }
       
   107  
       
   108  
       
   109 --- rsyslog/tools/omfwd.c.orig	2012-01-09 06:05:45.000000000 -0800
       
   110 +++ rsyslog/tools/omfwd.c	2013-12-02 09:01:51.293926230 -0800
       
   111 @@ -310,7 +310,7 @@
       
   112  
       
   113  	alreadySent = 0;
       
   114  dbgprintf("omfwd: XXXX: pData %p, pNetStrm %p\n", pData, pData->pNetstrm);
       
   115 -	netstrm.CheckConnection(pData->pNetstrm); /* hack for plain tcp syslog - see ptcp driver for details */
       
   116 +	CHKiRet(netstrm.CheckConnection(pData->pNetstrm)); /* hack for plain tcp syslog - see ptcp driver for details */
       
   117  	while(alreadySent != len) {
       
   118  		lenSend = len - alreadySent;
       
   119  		CHKiRet(netstrm.Send(pData->pNetstrm, buf+alreadySent, &lenSend));
       
   120 @@ -319,6 +319,12 @@
       
   121  	}
       
   122  
       
   123  finalize_it:
       
   124 +	if(iRet != RS_RET_OK) {
       
   125 +		/* error! */
       
   126 +		dbgprintf("TCPSendBuf error %d, destruct TCP Connection!\n", iRet);
       
   127 +		DestructTCPInstanceData(pData);
       
   128 +		iRet = RS_RET_SUSPENDED;
       
   129 +	}
       
   130  	RETiRet;
       
   131  }
       
   132  
       
   133 @@ -363,6 +369,7 @@
       
   134  {
       
   135  	DEFiRet;
       
   136  	instanceData *pData = (instanceData *) pvData;
       
   137 +	dbgprintf("TCPSendPrepRetry performs a DestructTCPInstanceData\n");
       
   138  
       
   139  	assert(pData != NULL);
       
   140  	DestructTCPInstanceData(pData);
       
   141 @@ -380,6 +387,7 @@
       
   142  
       
   143  	assert(pData != NULL);
       
   144  	if(pData->pNetstrm == NULL) {
       
   145 +		dbgprintf("TCPSendInit CREATE\n");
       
   146  		CHKiRet(netstrms.Construct(&pData->pNS));
       
   147  		/* the stream driver must be set before the object is finalized! */
       
   148  		CHKiRet(netstrms.SetDrvrName(pData->pNS, cs.pszStrmDrvr));
       
   149 @@ -403,6 +411,7 @@
       
   150  
       
   151  finalize_it:
       
   152  	if(iRet != RS_RET_OK) {
       
   153 +		dbgprintf("TCPSendInit FAILED with %d.\n", iRet);
       
   154  		DestructTCPInstanceData(pData);
       
   155  	}
       
   156