summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormreddy <mreddy>2006-10-18 04:22:48 +0000
committermreddy <mreddy>2006-10-18 04:22:48 +0000
commitf9a8d3bf5b0e527138a3b2f4872c21e58a2ee741 (patch)
treef32bab18590cb6c27bdd213c67a5584de9d79af2
parent9fd069f1822930e050574aae67da1aa3c84c76c5 (diff)
downloadtog-pegasus-TASK-BUG4011_WinLocalConnect-branch.zip
tog-pegasus-TASK-BUG4011_WinLocalConnect-branch.tar.gz
tog-pegasus-TASK-BUG4011_WinLocalConnect-branch.tar.xz
TITLE: Local Domain Sockets in Windows
-rw-r--r--src/Pegasus/Client/CIMClientRep.cpp17
-rw-r--r--src/Pegasus/Common/HTTPAcceptor.cpp17
-rw-r--r--src/Pegasus/Common/HTTPConnection.cpp16
-rw-r--r--src/Pegasus/Common/HTTPConnector.cpp19
-rw-r--r--src/Pegasus/Common/Monitor.cpp11
-rw-r--r--src/Pegasus/Common/NamedPipe.cpp15
-rw-r--r--src/Pegasus/Common/NamedPipe.h56
7 files changed, 85 insertions, 66 deletions
diff --git a/src/Pegasus/Client/CIMClientRep.cpp b/src/Pegasus/Client/CIMClientRep.cpp
index 4cd2eba..5d6075f 100644
--- a/src/Pegasus/Client/CIMClientRep.cpp
+++ b/src/Pegasus/Client/CIMClientRep.cpp
@@ -1096,12 +1096,25 @@ Message* CIMClientRep::_doRequest(
Uint64 nowMilliseconds = startMilliseconds;
Uint64 stopMilliseconds = nowMilliseconds + _timeoutMilliseconds;
- while (nowMilliseconds < stopMilliseconds)
+ while (nowMilliseconds < stopMilliseconds)
{
//
// Wait until the timeout expires or an event occurs:
//
- _monitor->run(Uint32(stopMilliseconds - nowMilliseconds));
+#if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
+ // if it is a local connection and NamedPipe feature is supported
+ // run monitor for timeout in a period of 1000 milliseconds
+ if (!_connectHost.size())
+ {
+ _monitor->run(Uint32(1000));
+ }
+ else
+ {
+#endif
+ _monitor->run(Uint32(stopMilliseconds - nowMilliseconds));
+#if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
+ }
+#endif
//
// Check to see if incoming queue has a message
diff --git a/src/Pegasus/Common/HTTPAcceptor.cpp b/src/Pegasus/Common/HTTPAcceptor.cpp
index 8f6c57d..0b48e83 100644
--- a/src/Pegasus/Common/HTTPAcceptor.cpp
+++ b/src/Pegasus/Common/HTTPAcceptor.cpp
@@ -768,9 +768,6 @@ void HTTPAcceptor::destroyConnections()
{
NamedPipe namedPipe = connection->getNamedPipe();
_monitor->unsolicitPipeMessages(namedPipe);
- ::FlushFileBuffers(namedPipe.getPipe());
- ::DisconnectNamedPipe(namedPipe.getPipe());
- ::CloseHandle(namedPipe.getPipe());
}
#endif
while (connection->refcount.get()) { }
@@ -938,7 +935,6 @@ void HTTPAcceptor::_createNamedPipe()
delete _rep;
_rep = 0;
//l10n
- //throw BindFailedException("Failed to solicit socket messaeges");
MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_SOLICIT_SOCKET_MESSAGES",
"Failed to solicit socket messaeges");
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
@@ -974,8 +970,6 @@ void HTTPAcceptor::_acceptNamedPipeConnection()
}
#endif
- // shouldnt we be using the private var....
- // _namedPipeServer->accept()
NamedPipeServerEndPiont nPSEndPoint = _rep->namedPipeServer->accept();
// Register to receive Messages on Connection pipe:
@@ -988,15 +982,6 @@ void HTTPAcceptor::_acceptNamedPipeConnection()
HTTPConnection* connection = new HTTPConnection(_monitor, nPSEndPoint,
this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection);
- /* NOT SURE WHAT TO DO HERE ....
- if (socketAcceptStatus == 0)
- {
- PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2,
- "HTTPAcceptor: SSL_accept() pending");
- connection->_acceptPending = true;
- }
- */
-
// Solicit events on this new connection's socket:
int index;
#ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
@@ -1016,8 +1001,6 @@ void HTTPAcceptor::_acceptNamedPipeConnection()
Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
"HTTPAcceptor::_acceptPipeConnection: Attempt to allocate entry in _entries table failed.");
delete connection;
- // May have to close the PIPE here...
- //Socket::close(socket);
return;
}
diff --git a/src/Pegasus/Common/HTTPConnection.cpp b/src/Pegasus/Common/HTTPConnection.cpp
index 47c1e2b..54b8628 100644
--- a/src/Pegasus/Common/HTTPConnection.cpp
+++ b/src/Pegasus/Common/HTTPConnection.cpp
@@ -862,8 +862,14 @@ Boolean HTTPConnection::_handleWriteEvent(Message &message)
if (!_namedPipeConnection)
{
_socket->enableBlocking();
- }// This condition for NamedPipe has been inplemented in
- // NamedPipe::write
+ }
+ else
+ {
+ // Wait for the client peer to read the data. This must be enabled
+ // for Chunking support.
+ ::FlushFileBuffers (_namedPipe.getPipe());
+
+ }
#else
_socket->enableBlocking();
@@ -1251,12 +1257,6 @@ Boolean HTTPConnection::_handleWriteEvent(Message &message)
{
_socket->disableBlocking();
}
- /* Reset the Pipe mode to NON-Blocking mode */
- else
- {
- DWORD dwModeReset= PIPE_READMODE_MESSAGE | PIPE_NOWAIT;
- ::SetNamedPipeHandleState( _namedPipe.getPipe(), &dwModeReset, NULL, NULL );
- }
#else
_socket->disableBlocking();
#endif
diff --git a/src/Pegasus/Common/HTTPConnector.cpp b/src/Pegasus/Common/HTTPConnector.cpp
index c77dd93..afcbb1f 100644
--- a/src/Pegasus/Common/HTTPConnector.cpp
+++ b/src/Pegasus/Common/HTTPConnector.cpp
@@ -29,18 +29,6 @@
//
//==============================================================================
//
-// Author: Mike Brasher (mbrasher@bmc.com)
-//
-// Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
-// (carolann_graves@hp.com)
-// Modified By: Sushma Fernandes, Hewlett-Packard Company
-// (sushma_fernandes@hp.com)
-// Modified By: Dan Gorey, IBM (djgorey@us.ibm.com)
-// Modified By: Amit Arora (amita@in.ibm.com) for Bug#1170
-// Dave Sudlik, IBM (dsudlik@us.ibm.com) for Bug#1462
-// Amit Arora, IBM (amita@in.ibm.com) for Bug#2541
-// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
-// David Dillard, Symantec Corp (david_dillard@symantec.com)
//
//%/////////////////////////////////////////////////////////////////////////////
@@ -603,13 +591,18 @@ void HTTPConnector::_deleteConnection(HTTPConnection* httpConnection)
#if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
HTTPConnection* HTTPConnector::_connectNamedPipe(MessageQueue* outputMessageQueue)
{
- NamedPipeClient client(PEGASUS_NAMEDPIPE_PATH);
+ //Create a temporary named pipe of client
+ NamedPipeClient client(PEGASUS_NAMEDPIPE_PATH);
#ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
{
AutoMutex automut(Monitor::_cout_mut);
PEGASUS_STD(cout) << "In HTTPConnector::_connectNamedPipe after client constuctor" << PEGASUS_STD(endl);
}
#endif
+ // Make the connect request. This would challenge the server for handshake by writing the data
+ // <connect-request> . If the server responds by writing <connect-response>, a
+ // NamedPipeClientEndPoint pipe is created by the client.
+
NamedPipeClientEndPiont nPCEndPoint = client.connect();
#ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
diff --git a/src/Pegasus/Common/Monitor.cpp b/src/Pegasus/Common/Monitor.cpp
index e42647f..008a73d 100644
--- a/src/Pegasus/Common/Monitor.cpp
+++ b/src/Pegasus/Common/Monitor.cpp
@@ -749,6 +749,8 @@ Boolean Monitor::run(Uint32 milliseconds)
entries.reset(_entries);
entries[indx]._status = _MonitorEntry::IDLE;
handled_events = true;
+ delete [] hPipeList;
+ return handled_events;
}
}
@@ -758,7 +760,8 @@ Boolean Monitor::run(Uint32 milliseconds)
handled_events = true;
}
}
- return(handled_events);
+ delete [] hPipeList;
+ return handled_events;
}
@@ -790,7 +793,6 @@ Boolean Monitor::run(Uint32 milliseconds)
for (int pipeIndex = 0; pipeIndex < pipeEntryCount; pipeIndex++)
{
dwBytesAvail = 0;
- Tracer::trace(TRC_HTTP,Tracer::LEVEL4," PIPE_PEEKING for PIPE = %u ", hPipeList[pipeIndex]);
bPeekPipe = ::PeekNamedPipe(hPipeList[pipeIndex],
NULL,
NULL,
@@ -806,7 +808,6 @@ Boolean Monitor::run(Uint32 milliseconds)
Tracer::trace(TRC_HTTP,Tracer::LEVEL4," PIPE_PEEKING FOUND = %u BYTES", dwBytesAvail);
pEvents = 1;
- Tracer::trace(TRC_HTTP, Tracer::LEVEL4, "EVENT TRIGGERED in Pipe = %u ",entries[indexPipeCountAssociator[pipeIndex]].namedPipe.getPipe());
entries[indexPipeCountAssociator[pipeIndex]].pipeSet = true;
Tracer::trace(TRC_HTTP, Tracer::LEVEL4,
"Monitor::run select event received events = %d, \
@@ -905,7 +906,9 @@ Boolean Monitor::run(Uint32 milliseconds)
autoEntryMutex.lock();
entries.reset(_entries);
entries[pIndx]._status = _MonitorEntry::IDLE;
- return true;
+ delete [] hPipeList;
+ return(handled_events);
+
}
diff --git a/src/Pegasus/Common/NamedPipe.cpp b/src/Pegasus/Common/NamedPipe.cpp
index 9cec4e1..d02b985 100644
--- a/src/Pegasus/Common/NamedPipe.cpp
+++ b/src/Pegasus/Common/NamedPipe.cpp
@@ -152,15 +152,11 @@ bool NamedPipe::write(HANDLE pipe, String & buffer, LPOVERLAPPED overlap)
printf("WriteFile in NamedPipe::write failed with error \
%d: %s", dw, lpMsgBuf);
#endif
- //LocalFree(lpMsgBuf);
LocalFree(lpDisplayBuf);
- //ExitProcess(dw);
return false;
}
}
- // Wait for the client peer to read the data. This must be enabled
- // for Chunking support
- ::FlushFileBuffers (pipe);
+
return(true);
}
@@ -179,13 +175,13 @@ NamedPipeServer::NamedPipeServer(const String & pipeName)
_pipe.hpipe =
::CreateNamedPipe(
_PRIMARY_PIPE_NAME(_name).getCString(),
- PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write
+ PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
- MAX_PIPE_INSTANCES, // PIPE_UNLIMITED_INSTANCES, // max. instances??
+ MAX_PIPE_INSTANCES,
NAMEDPIPE_MAX_BUFFER_SIZE,
NAMEDPIPE_MAX_BUFFER_SIZE,
MAX_TIMEOUT,
- 0); // NULL ??
+ 0);
if (_pipe.hpipe == INVALID_HANDLE_VALUE)
{
@@ -214,6 +210,9 @@ NamedPipeServer::NamedPipeServer(const String & pipeName)
if (bIsconnected)
{
//SHOULD THROW AN EXCEPTION HERE
+ throw(Exception("NamedPipeServer::accept Primary - Pipe Failed to \
+ reconnect."));
+
}
}
diff --git a/src/Pegasus/Common/NamedPipe.h b/src/Pegasus/Common/NamedPipe.h
index d643465..10bb6fd 100644
--- a/src/Pegasus/Common/NamedPipe.h
+++ b/src/Pegasus/Common/NamedPipe.h
@@ -43,7 +43,7 @@
PEGASUS_USING_PEGASUS;
PEGASUS_USING_STD;
-const DWORD NAMEDPIPE_MAX_BUFFER_SIZE = 8192;
+const DWORD NAMEDPIPE_MAX_BUFFER_SIZE = 8192;
typedef struct
{
@@ -57,27 +57,55 @@ class PEGASUS_COMMON_LINKAGE NamedPipe
public:
static bool read(HANDLE pipe, String & buffer);
static bool write(HANDLE pipe, String & buffer, LPOVERLAPPED overlap = NULL);
- String getName(void) {return _name;}
+ String getName(void)
+ {
+ return _name;
+ }
- HANDLE getPipe(void){ return _pipe.hpipe;}
- LPOVERLAPPED getOverlap(void){ return &_pipe.overlap;}
+ HANDLE getPipe(void)
+ {
+ return _pipe.hpipe;
+ }
+
+ LPOVERLAPPED getOverlap(void)
+ {
+ return &_pipe.overlap;
+ }
Boolean isConnectionPipe;
char raw[NAMEDPIPE_MAX_BUFFER_SIZE];
-
+
DWORD bytesRead;
-
- void setPipeHandle()
+
+ void setPipeHandle()
{
_pipe.hpipe=INVALID_HANDLE_VALUE;
}
- bool _isUnderUse(){ return _isBusy; }
- void resetState() { _isBusy = false; }
- void setBusy() { _isBusy = true; }
+ bool _isUnderUse()
+ {
+ return _isBusy;
+ }
+ void resetState()
+ {
+ _isBusy = false;
+ }
+ void setBusy()
+ {
+ _isBusy = true;
+ }
- bool isConnected(){ return _isConnected; }
- void disconnect() { _isConnected = false; }
- void connected() { _isConnected = true; }
+ bool isConnected()
+ {
+ return _isConnected;
+ }
+ void disconnect()
+ {
+ _isConnected = false;
+ }
+ void connected()
+ {
+ _isConnected = true;
+ }
protected:
String _name;
@@ -125,7 +153,7 @@ public:
NamedPipeClientEndPiont connect(void);
void disconnect(HANDLE pipe) const;
-
+
private: