Организация удаленного доступа к распределенным базам данных
Рефераты >> Программирование и компьютеры >> Организация удаленного доступа к распределенным базам данных

LogEvent(EVENTLOG_INFORMATION_TYPE, "\"Svyazinform\" Communicatin Service Paused");

}

void ServerDoContinue()

{

ResumeThread(&ShedulingThread);

ResumeThread(&ClientHandlingThread);

LogEvent(EVENTLOG_INFORMATION_TYPE, "\"Svyazinform\" Communicatin Service Resumed");

}

void ServerDoStop() {

RPC_STATUS status;

status = RpcMgmtStopServerListening(NULL);

if (status != NO_ERROR) {

// Error handling

}

status = RpcServerUnregisterIf(NULL, NULL, FALSE);

if (status != NO_ERROR) {

// Error handling

}

TerminateTasks();

WaitForSingleObject(&ClientHandlingThread, 5000);

CloseHandle(&ClientHandlingThread);

InterlockedIncrement(&TerminateSheduling);

WaitForSingleObject(&ShedulingThread, 5000);

CloseHandle(&ShedulingThread);

WaitForSingleObject(hConfigMutex, 3000);

ReleaseMutex(hConfigMutex);

CloseHandle(hConfigMutex);

WaitForSingleObject(hTaskMutex, 3000);

ReleaseMutex(hTaskMutex);

CloseHandle(hTaskMutex);

LogEvent(EVENTLOG_INFORMATION_TYPE, "\"Svyazinform\" Communicatin Service Stopped");

}

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

/* MIDL allocate and free */

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

void RPC_FAR * RPC_USER midl_user_allocate(size_t len)

{

return(malloc(len));

}

void RPC_USER midl_user_free(void RPC_FAR * ptr)

{

free(ptr);

}

ClientHandler.c

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

/* Этот модуль обрабатывает подключения клиентов */

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

#include <windows.h>

#include "ClientHandler.h"

#include "CommonConfig.h"

#include " /Comm.h"

DWORD ClientHandlingThread;

DWORD WINAPI RPCClientHandling(LPVOID ThreadParm)

{

RPC_STATUS status;

status = RpcServerListen(

cMinCalls,

cMaxCalls,

fDontWait);

if (status != NO_ERROR) {

return 1;

}

return 0;

}

void RefreshIniProps()

{

MessageBeep(1);

return;

}

EventLog.c

#include <windows.h>

#include "EventLog.h"

void LogEvent(WORD EventType, LPSTR EventMsg)

{

HANDLE h;

h = RegisterEventSource(NULL, /* uses local computer */

"CommServ"); /* source name */

if (h != NULL)

{

ReportEvent(h, /* event log handle */

EventType, /* event type */

0, /* category zero */

0x1003, /* event identifier */

NULL, /* no user security identifier */

1, /* one substitution string */

0, /* no data */

&EventMsg, /* address of string array */

NULL); /* address of data */

DeregisterEventSource(h);

}

return;

}

Comm_s.c

/* this ALWAYS GENERATED file contains the RPC server stubs */

/* File created by MIDL compiler version 3.00.15 */

/* at Tue Jun 03 11:35:46 1997

*/

/* Compiler settings for comm.idl:

Os, W1, Zp8, env=Win32, ms_ext, c_ext, oldnames

error checks: none

*/

//@@MIDL_FILE_HEADING( )

#include <string.h>

#include "comm.h"

#define TYPE_FORMAT_STRING_SIZE 1

#define PROC_FORMAT_STRING_SIZE 3

typedef struct _MIDL_TYPE_FORMAT_STRING

{

short Pad;

unsigned char Format[ TYPE_FORMAT_STRING_SIZE ];

} MIDL_TYPE_FORMAT_STRING;

typedef struct _MIDL_PROC_FORMAT_STRING

{

short Pad;

unsigned char Format[ PROC_FORMAT_STRING_SIZE ];

} MIDL_PROC_FORMAT_STRING;

extern const MIDL_TYPE_FORMAT_STRING MIDLTypeFormatString;

extern const MIDL_PROC_FORMAT_STRING MIDLProcFormatString;

/* Standard interface: CommService, ver. 1.0,

GUID={0x4a25d2e0,0x6703,0x11d0,{0x89,0x27,0x00,0xa0,0x24,0x13,0x85,0x0e}} */

extern RPC_DISPATCH_TABLE CommService_DispatchTable;

static const RPC_SERVER_INTERFACE CommService _RpcServerInterface =

{

sizeof(RPC_SERVER_INTERFACE),

{{0x4a25d2e0,0x6703,0x11d0,{0x89,0x27,0x00,0xa0,0x24,0x13,0x85,0x0e}},{1,0}},

{{0x8A885D04,0x1CEB,0x11C9,{0x9F,0xE8,0x08,0x00,0x2B,0x10,0x48,0x60}},{2,0}},

&CommService_DispatchTable,

0,

0,

0,

0,

0

};

RPC_IF_HANDLE CommService_ServerIfHandle = (RPC_IF_HANDLE)& CommService _RpcServerInterface;

extern const MIDL_STUB_DESC CommService_StubDesc;

void RPC_STUB

CommService_RefreshIniProps(

PRPC_MESSAGE _pRpcMessage )

{

MIDL_STUB_MESSAGE _StubMsg;

RPC_STATUS _Status;

((void)(_Status));

NdrServerInitializeNew(

_pRpcMessage,

&_StubMsg,

&CommService_StubDesc);

RpcTryFinally

{

RefreshIniProps();

}

RpcFinally

{

}

RpcEndFinally

_pRpcMessage->BufferLength =

(unsigned int)((long)_StubMsg.Buffer - (long)_pRpcMessage->Buffer);

}

static const MIDL_STUB_DESC CommService_StubDesc =

{

(void RPC_FAR *)& CommService _RpcServerInterface,

MIDL_user_allocate,

MIDL_user_free,

0,

0,

0,

0,

0,

MIDLTypeFormatString.Format,

0, /* -error bounds_check flag */

0x10001, /* Ndr library version */

0,

0x300000f, /* MIDL Version 3.0.15 */

0,

0,

0, /* Reserved1 */

0, /* Reserved2 */

0, /* Reserved3 */

0, /* Reserved4 */

0 /* Reserved5 */

};

static RPC_DISPATCH_FUNCTION CommService_table[] =

{

CommService_RefreshIniProps,

0

};

RPC_DISPATCH_TABLE CommService_DispatchTable =

{

1,

CommService_table

};

#if !defined( RPC_WIN32 )

#error Invalid build platform for this stub.

#endif

static const MIDL_PROC_FORMAT_STRING MIDLProcFormatString =

{

0,

{

0x5b, /* FC_END */

0x5c, /* FC_PAD */

0x0

}

};

static const MIDL_TYPE_FORMAT_STRING MIDLTypeFormatString =

{

0,

{

0x0

}

};

ShedulerServ.c

/**********************************************************//* Task Sheduler

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

#include <windows.h>

#include "ShedulerServ.h"

#include "CommonConfig.h"

#include "EventLog.h"

#define SLEEP_INTERVAL 5000

#define ACTIVATE_INTERVAL 60000

BOOL TerminateSheduling = FALSE;

DWORD ShedulingThread;

DWORD WINAPI TaskProc(LPVOID ThreadParm);

void AnalyseTaskTable();

DWORD GetTimeInMins();

DWORD WINAPI ShedulingProc(LPVOID ThreadParm)

{

long i = 0;

while (!TerminateSheduling) {

if ((i += SLEEP_INTERVAL) >= ACTIVATE_INTERVAL) {

i = 0;

if (TaskCount == 0) UpdateVariables();

AnalyseTaskTable();

}

Sleep(SLEEP_INTERVAL);

}

return 0;

}

DWORD WINAPI TaskProc(LPVOID ThreadParm)


Страница: