crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs

netbuffer.c (1075B)


      1 /*************************************************************************
      2  * This file is part of Crosroads 1.23, a load balancer and fail over
      3  * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL.
      4  * Visit http://crossroads.e-tunity.com for information.
      5  *************************************************************************/
      6 #include "crossroads.h"
      7 
      8 unsigned char *net_buffer (CopyDirection dir, unsigned *sz) {
      9     if (dir == dir_server_to_client) {
     10 	if (srbufmax) {
     11 	    *sz = srbufmax - srbufpos;
     12 	    msg ("Service %s: %d bytes still in server buffer",
     13 		 activeservice->name, *sz);
     14 	    srbufmax = 0;
     15 	    return (srbuf + srbufpos);
     16 	} else {
     17 	    msg ("Service %s: server buffer is empty",
     18 		 activeservice->name);
     19 	    return (0);
     20 	}
     21     } else {
     22 	if (clbufmax) {
     23 	    *sz = clbufmax - clbufpos;
     24 	    msg ("Service %s: %d bytes still in client buffer",
     25 		 activeservice->name, *sz);
     26 	    clbufmax = 0;
     27 	    return (clbuf + clbufpos);
     28 	} else {
     29 	    msg ("Service %s: client buffer is empty",
     30 		 activeservice->name);
     31 	    return (0);
     32 	}
     33     }
     34 }