CVS diff for defines.h between 1.13 and 1.6:

Revision 1.6 Revision 1.13
 
#include "config.h"
 
/* 
* Maximum number of handler threads. Can be overridden in config file 
* with the NumHands option. 
*/ 
#define COW_NOHAND 16
/* 
* Maximum number of handler threads. Can be overridden in config file 
* with the NumHands option. 
*/ 
#define COW_NOHAND 16
 
/*
 * We use pmsg's from a pre-allocated pool to avoid malloc/free overhead.
 * We want to actually allocate a multiple of the number of handler threads
 * we have in order to let the depot queue up some requests.  This constant
 * sets that multiple.  The total size of the pmsg pool will be
 * cow_nohand*POOL_SIZE_FACT.
 */
#define POOL_SIZE_FACT 4

/*
 * Using writev() to combine outgoing buffers should be faster than issuing
 * multiple write()'s.
 */
//#define USE_WRITEV

/*
 * Limiting the number of threads that can be responding over the socket should
 * increase the average transfer speed of each request (although it will
 * obviously increase the amount of time before the first byte is sent back).
 * 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 SOCKETBUF_SIZE 8192 
//#define SOCKETBUF_SIZE 1024*16 // ok. 
 
//#define SOCKETBUF_SIZE 8192 
//#define SOCKETBUF_SIZE 1024*16 // ok. 
Line 63 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) { \
            perror("close");                                        \ 
            perror(__FILE__ " :: close");                           \ 
            exit(errno);                                            \ 
} \ 
} else { \ 
--cow_noof; \ 
} \ 
}
            exit(errno);                                            \ 
} \ 
} else { \ 
--cow_noof; \ 
} \ 
}
# endif
// close if fail set errno {EBADF|EINTR}. 
 

            

            
 
#ifdef USE_TCPCORK
#define SOCKTYPE int
#else
#define SOCKTYPE BUFF*
#endif 

            

            
#define COW_SEND_R(FD,BUF,RET) { \
int sent,head=0;\
int rem=strlen(BUF);\
while( 0< \
(sent = pth_send(FD, BUF+head, rem,0))\
     ) { pth_yield(NULL); head += sent; rem-=sent; if(1>rem)break;}\
RET=sent;}

#define COW_SEND_EV(FD,BUF,SEC,USEC) { \
#ifdef LOGGING
#define LOG(l,m)        fprintf(l, m)
#define LOG1(l,m,a1)    fprintf(l, m, a1)
#define LOG2(l,m,a1,a2) fprintf(l, m, a1, a2)
#else
#define LOG(l,m)
#define LOG1(l,m,a1)
#define LOG2(l,m,a1,a2)
#endif 
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-=head; \
         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 COWDEBUG 
#define PRINT(m) printf(m) 
 
#ifdef COWDEBUG 
#define PRINT(m) printf(m) 
Line 190 Line 138
#define PRINT5(m,a1,a2,a3,a4,a5) 
#endif 
 
#define PRINT5(m,a1,a2,a3,a4,a5) 
#endif 
 


Legend
Lines deleted from 1.13  
Lines Modified
  Lines added in revision 1.6