Revision 1.9 |
Revision 1.13 |
|
#include "config.h"
|
/* * Maximum number of handler threads. Can be overridden in config file * with the NumHands option.
|
/* * Maximum number of handler threads. Can be overridden in config file * with the NumHands option.
|
Line 17 |
Line 19 |
* Using writev() to combine outgoing buffers should be faster than issuing * multiple write()'s. */
|
* Using writev() to combine outgoing buffers should be faster than issuing * multiple write()'s. */
|
#define USE_WRITEV
|
//#define USE_WRITEV
|
/* * Limiting the number of threads that can be responding over the socket should
|
/* * Limiting the number of threads that can be responding over the socket should
|
Line 26 |
Line 28 |
* It is interesting to tune this number and watch the performance impact. * Leaving this undefined will allow all threads to send data concurrently. */
|
* It is interesting to tune this number and watch the performance impact. * Leaving this undefined will allow all threads to send data concurrently. */
|
#define RESPONSE_CONCURRENCY 1
|
//#define RESPONSE_CONCURRENCY 1
|
//#define SOCKETBUF_SIZE 8192 //#define SOCKETBUF_SIZE 1024*16 // ok.
|
//#define SOCKETBUF_SIZE 8192 //#define SOCKETBUF_SIZE 1024*16 // ok.
|
Line 87 |
Line 89 |
#define KA_MAX_DUR 10 /* max seconds of ka duration */ /* default values for port operations */
|
#define KA_MAX_DUR 10 /* max seconds of ka duration */ /* default values for port operations */
|
#define COW_RTO_S 3 /* recv or read from port TimeOut value (sec)*/
#define COW_RTO_U 10000 /* recv or read from port TimeOut value (usec)*/
|
#define COW_RTO_S 15 /* recv or read from port TimeOut value (sec)*/
#define COW_RTO_U 0 /* recv or read from port TimeOut value (usec)*/
|
/* currently not used (do we need these?) */ #define COW_WTO_S 0 /* same for write or send (but probably */ #define COW_WTO_U 1000 /* not needed cuz write error -> immediate -1 */
|
/* currently not used (do we need these?) */ #define COW_WTO_S 0 /* same for write or send (but probably */ #define COW_WTO_U 1000 /* not needed cuz write error -> immediate -1 */
|
/* ugly macros */
# undef DB_FDX
# ifdef DB_FDX
#define DEB_FDX(X) \
{ \
static int debug_op[1024]; \
static int i,j=0,k; \
for(i=0; i<1024; i++) { \
debug_op[i]=open("/dev/null", O_RDONLY); \
if(debug_op[i]>0) j++; \
} \
k=j;\
for(i=0; i<1024; i++) { \
if(0==close(debug_op[i])) j--; \
} \
if(j) perror("close counter != 0"); \
*X = k; \
}
#else
#define DEB_FDX(X) /* nothing */
#endif
#ifdef DB_FDX
#define COW_CLOSE(FD) { \
static int x, y, z=0; \
DEB_FDX(&x) \
if (close(FD)) { \
if (EBADF!=errno) { \
perror("close"); \
exit(errno); \
} \
} else { \
--cow_noof; \
z=1; \
} \
DEB_FDX( &y ) \
if (x != y - z) { \
printf("ERROR in COW_CLOSE where x,y = %d, %d\n", x, y); \
exit(-1); \
} \
}
#else
|
|
#define COW_CLOSE(FD) { \ if (close(FD)) { \ if (EBADF != errno) { \
|
#define COW_CLOSE(FD) { \ if (close(FD)) { \ if (EBADF != errno) { \
|
Line 145 |
Line 105 |
--cow_noof; \ } \ }
|
--cow_noof; \ } \ }
|
# endif
// close if fail set errno {EBADF|EINTR}.
|
|
|
|
#define COW_SEND_R(FD,BUF,RET) { \
int head=0; \
int rem = strlen(BUF); \
while(0 < (RET = pth_send(FD, BUF+head, rem,0))) { \
|
#ifdef USE_TCPCORK
#define SOCKTYPE int
#else
#define SOCKTYPE BUFF*
#endif
|
pth_yield(NULL); \
head += RET; \
rem -= RET; \
if(1 > rem) \
break; \
} \
}
#define COW_SEND_EV(FD,BUF,SEC,USEC) { \
int sent, head=0; \
int left = strlen(BUF); \
pth_event_t ev = NULL; \
ev = pth_event(PTH_EVENT_TIME, pth_timeout(SEC,USEC)); \
while(0 < (sent = pth_send_ev(FD, BUF+head, left, 0, ev))) { \
head += sent; left -= sent; \
if(0 == left) break; \
if(0 > sent) break; \
pth_yield(NULL); \
} \
pth_event_free(ev, PTH_FREE_THIS); \
if(0>sent) return -1; \
}
#define COW_SEND(FD,BUF) COW_SEND_EV(FD,BUF,1,0)
// debug
// there's a way to get some info from kernel on linux, but i don't remember
// off brain. What about other posix os?
# ifdef DB_FDX
#define DEB_FD \
{ \
static int debug_op[1024]; \
static int i,j=0,k; \
for(i=0; i<1024; i++) { \
debug_op[i]=open("/dev/null", O_RDONLY); \
if(debug_op[i]>0) j++; \
} \
k=j;printf("(%d)\n",j); \
for(i=0; i<1024; i++) { \
if(0==close(debug_op[i])) j--; \
} \
if(j) perror("close counter != 0"); \
}
# else
#define DEB_FD /* nothing */
# endif
|
|
#ifdef LOGGING #define LOG(l,m) fprintf(l, m)
|
#ifdef LOGGING #define LOG(l,m) fprintf(l, m)
|
Line 209 |
Line 121 |
#define LOG1(l,m,a1) #define LOG2(l,m,a1,a2) #endif
|
#define LOG1(l,m,a1) #define LOG2(l,m,a1,a2) #endif
|
|
|
#ifdef COWDEBUG #define PRINT(m) printf(m)
|
#ifdef COWDEBUG #define PRINT(m) printf(m)
|
Line 227 |
Line 138 |
#define PRINT5(m,a1,a2,a3,a4,a5) #endif
|
#define PRINT5(m,a1,a2,a3,a4,a5) #endif
|