Browse Source

- tsend_* functions changed to obey the timeout more accurately and in all
cases
- unix_tx_timeout changed to milliseconds and its default value to 500 ms.

Andrei Pelinescu-Onciul 20 years ago
parent
commit
3ba4048bcc
5 changed files with 39 additions and 5 deletions
  1. 1 1
      Makefile.defs
  2. 2 0
      NEWS
  3. 22 0
      modules/tm/doc/params.xml
  4. 2 2
      modules/tm/t_fifo.c
  5. 12 2
      tsend.c

+ 1 - 1
Makefile.defs

@@ -61,7 +61,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 10
 SUBLEVEL =   99
-EXTRAVERSION = -dev26-tm-timers
+EXTRAVERSION = -dev27-tm-timers
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 2 - 0
NEWS

@@ -27,6 +27,8 @@ modules:
                          delete_timer, retr_timer1, retr_timer2
                        - retr_timer1 (first retransmission) changed to 500 ms
                        - delete_timer changed to 200 ms
+                       - unix_tx_timeout expressed now in milliseconds; default
+                         value changed to 500 ms
              - functions:
                        - new t_set_fr(timeout_fr_inv, timeout_fr) -- allows
                          changing the transaction timer from script, even if

+ 22 - 0
modules/tm/doc/params.xml

@@ -155,4 +155,26 @@ modparam("tm", "noisy_ctimer", 1)
 	</example>
     </section>
 
+	<section id="unix_tx_timeout">
+	<title><varname>unix_tx_timeout</varname> (integer)</title>
+	<para>
+		Unix socket transmission timeout, in milliseconds.
+	</para>
+	<para>
+		If unix sockets are used (e.g.: to communicate with sems) and sending
+		a message on a unix socket takes longer then 
+		<varname>unix_tx_timeout</varname>, the send will fail.
+	</para>
+	<para>
+	    The default value is 500 milliseconds.
+	</para>
+	<example>
+	    <title>Set <varname>unix_tx_timeout</varname> parameter</title>
+	    <programlisting>
+...
+modparam("tm", "unix_tx_timeout", 250)
+...
+	    </programlisting>
+	</example>
+	</section>
 </section>

+ 2 - 2
modules/tm/t_fifo.c

@@ -82,7 +82,7 @@
 
 
 
-int tm_unix_tx_timeout = 2; /* Default is 2 seconds */
+int tm_unix_tx_timeout = 500; /* Default is 500 ms */
 
 #define TWRITE_PARAMS          20
 #define TWRITE_VERSION_S       "0.3"
@@ -952,7 +952,7 @@ static int write_to_unixsock(char* sockname, int cnt)
 		return -1;
 	}
 
-	if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt, tm_unix_tx_timeout * 1000) < 0) {
+	if (tsend_dgram_ev(sock, iov_lines_eol, 2 * cnt, tm_unix_tx_timeout) < 0) {
 		LOG(L_ERR, "write_to_unixsock: writev failed: %s\n", strerror(errno));
 		return -1;
 	}

+ 12 - 2
tsend.c

@@ -42,18 +42,28 @@
 #include <sys/uio.h>
 
 #include "dprint.h"
+#include "timer.h"
+#include "timer_ticks.h"
 
 /* the functions below are very similar => some generic macros */
 #define TSEND_INIT \
 	int n; \
 	struct pollfd pf; \
+	ticks_t expire; \
+	s_ticks_t diff; \
+	expire=get_ticks_raw()+MS_TO_TICKS((ticks_t)timeout); \
 	pf.fd=fd; \
 	pf.events=POLLOUT
 
 #define TSEND_POLL(f_name) \
 poll_loop: \
 	while(1){ \
-		n=poll(&pf, 1, timeout); \
+		diff=expire-get_ticks_raw(); \
+		if (diff<=0){ \
+			LOG(L_ERR, "ERROR: " f_name ": send timeout (%d)\n", timeout); \
+			goto error; \
+		} \
+		n=poll(&pf, 1, TICKS_TO_MS((ticks_t)diff)); \
 		if (n<0){ \
 			if (errno==EINTR) continue; /* signal, ignore */ \
 			LOG(L_ERR, "ERROR: " f_name ": poll failed: %s [%d]\n", \
@@ -61,7 +71,7 @@ poll_loop: \
 			goto error; \
 		}else if (n==0){ \
 			/* timeout */ \
-			LOG(L_ERR, "ERROR: " f_name ": send timeout (%d)\n", timeout); \
+			LOG(L_ERR, "ERROR: " f_name ": send timeout (p %d)\n", timeout); \
 			goto error; \
 		} \
 		if (pf.revents&POLLOUT){ \