X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Ft-server.cpp;h=df398890607b98104f3e70ec7d5c1ca772c5e3af;hp=f64999f445d9ce75b1636e522061df021bfd7aa9;hb=7fa984c171c65d05d34775c4533808793b2109cb;hpb=d7f41f16caf965adb1a5ffcdaa937787dfcc030a diff --git a/src/t-server.cpp b/src/t-server.cpp index f64999f..df39889 100644 --- a/src/t-server.cpp +++ b/src/t-server.cpp @@ -1,9 +1,20 @@ -/* - * Copyright (c) 1998-2005, Index Data. - * See the file LICENSE for details. - * - * $Id: t-server.cpp,v 1.2 2005-06-25 15:58:33 adam Exp $ - */ +/* This file is part of YAZ proxy + Copyright (C) 1998-2009 Index Data + +YAZ proxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include #include @@ -11,45 +22,18 @@ #include #include #include "msg-thread.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#if HAVE_UNISTD_H +#include +#endif using namespace yazpp_1; -class Mutex { -public: - Mutex(); - ~Mutex(); - void lock(); - void unlock(); -private: - pthread_mutex_t m_mutex; - -}; - -Mutex::Mutex() -{ - pthread_mutex_init(&m_mutex, 0); -} - -Mutex::~Mutex() -{ - pthread_mutex_destroy(&m_mutex); -} - -void Mutex::lock() -{ - pthread_mutex_lock(&m_mutex); -} - -void Mutex::unlock() -{ - pthread_mutex_unlock(&m_mutex); -} - - class MyServer; class Auth_Msg : public IMsg_Thread { @@ -90,11 +74,18 @@ IMsg_Thread *Auth_Msg::handle() { case Z_APDU_initRequest: apdu = zget_APDU(odr, Z_APDU_initResponse); + ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_triggerResourceCtrl); + ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_search); + ODR_MASK_SET(apdu->u.initResponse->options, Z_Options_present); break; case Z_APDU_searchRequest: +#if HAVE_UNISTD_H sleep(5); +#endif apdu = zget_APDU(odr, Z_APDU_searchResponse); break; + case Z_APDU_triggerResourceControlRequest: + break; default: apdu = zget_APDU(odr, Z_APDU_close); m_close_flag = 1; @@ -148,6 +139,7 @@ void Auth_Msg::result() } if (m_front->m_delete_flag && m_front->m_no_requests == 0) delete m_front; + delete this; } MyServer::MyServer(IPDU_Observable *the_PDU_Observable, @@ -216,14 +208,18 @@ int main(int argc, char **argv) int ret; const char *addr = "tcp:@:9999"; char *apdu_log = 0; + int no_threads = 1; - while ((ret = options("a:v:T", argv, argc, &arg)) != -2) + while ((ret = options("n:a:v:T", argv, argc, &arg)) != -2) { switch (ret) { case 0: addr = xstrdup(arg); break; + case 'n': + no_threads = atoi(arg); + break; case 'a': apdu_log = xstrdup(arg); break; @@ -245,7 +241,7 @@ int main(int argc, char **argv) MyServer *z = 0; - Msg_Thread *my_thread = new Msg_Thread(&mySocketManager); + Msg_Thread *my_thread = new Msg_Thread(&mySocketManager, no_threads); #if YAZ_POSIX_THREADS if (thread_flag) @@ -273,6 +269,7 @@ int main(int argc, char **argv) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab