#define PORTPGSERVER 1999
//#define PATH "/home/jsalas/dcadena/bdreplicadasDavid/"
//#define IDNODE 0
//#define MAXQM 3


#include <string.h>
#include <stdio.h>

#include "declarations.h"

// socket support
#include "socku.h"

// postgres
#include <libpq-fe.h>

// client connection
#include "pgconnection.h"

// ensemble
#include "hot_sys.h"
#include "hot_error.h"
#include "hot_msg.h"
#include "hot_ens.h"
#include "hot_thread.h"

//semaphore
#include "semaphore.h"

// threads
#include "threads.h"

#ifndef _PGSERVER
//Define in StartServer int sock_server;
//int sockThread[MAXCLIENTS];
int freeThreads [MAXCLIENTS];
// semaphores of the Threads
semaphore semaThreads[MAXCLIENTS];
// socket to obtain the response of QM
int sockResTh[MAXCLIENTS/*-1 JSalas*/];
// socket to comunicate Groupcomm whith Threads
//int sockResGC[MAXQM];

int sockConnectionDriver[MAXCLIENTS];

// bdname the connection asociated to thread
char threadInformation[MAXCLIENTS][TAMBUFFER /*+ EXTRASIZE - RMEXTRASIZE*/];
// idConnection of the thread if is reconnection
hot_uint32 threadIdConnection[MAXCLIENTS];

semaphore mutexSequence;

semaphore semaConnections[MAXCLIENTS];

// sequence to tid
static int sequence=1;


int StartServer();
int getFreeThread();
void freeThread(int thId, int options);
void initFreeThreads ();

#define _PGSERVER
#endif

