/*****************************************************************************/
/*
                                  Throttle.h
*/
/*****************************************************************************/

#ifndef THROTTLE_H_LOADED
#define THROTTLE_H_LOADED 1

#include "wasd.h"

/**************/
/* structures */
/**************/

typedef struct ThrottlePerUserStruct THROTTLE_PER_USER_STRUCT;

struct ThrottlePerUserStruct
{
   int  CurrentProcessingCount,
        CurrentQueuedCount,
        TotalCount;
   char  RemoteUser [AUTH_MAX_USERNAME_LENGTH+1];
   struct ThrottlePerUserStruct  *NextUserPtr;
};

typedef struct ThrottleStruct THROTTLE_STRUCT;

struct ThrottleStruct
{
   /* count of requests for this path currently being processed */
   int  CurrentProcessingCount,
        CurrentQueuedCount,
        CurrentPerUserCount,
        MaxPerUserCount,
        MaxProcessingCount,
        MaxQueuedCount,
        Total503Count,
        TotalCount,
        TotalQueuedCount,
        TotalFiFoCount,
        TotalTimeoutBusyCount,
        TotalTimeoutQueueCount;

   /* for per-user queueing */
   struct ThrottlePerUserStruct  *FirstUserPtr;

   /* list of pointers to requests waiting for processing */
   LIST_HEAD  QueuedList;
};

/***********************/
/* function prototypes */
/***********************/

ThrottleBegin (REQUEST_STRUCT*);
ThrottleControl (BOOL, int, char*, char*);
ThrottleEnd (REQUEST_STRUCT*);
ThrottleInit ();
ThrottleMonitorReset ();
ThrottleRelease (REQUEST_STRUCT*, THROTTLE_PER_USER_STRUCT*, int);
ThrottleReport (REQUEST_STRUCT*);
ThrottleTimeout (REQUEST_STRUCT*);
ThrottleZero ();

#endif /* THROTTLE_H_LOADED */

/*****************************************************************************/
