From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:17:02 +0000 (-0700) Subject: HGFS: Clean up server transport session usage X-Git-Tag: 2013.09.16-1328054~102 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7230cb3017b18946be3e056d47a3a5e3293b8f09;p=thirdparty%2Fopen-vm-tools.git HGFS: Clean up server transport session usage The transport session is only ever used in the common HGFS server code. The scope should be constrained to that file and beyond that treated as an opaque type. Make some of the transport session functions static to the common HGFS server file and remove the declarations from the common header file. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/hgfsServer/hgfsServer.c b/open-vm-tools/lib/hgfsServer/hgfsServer.c index 1835bb818..fc34c277d 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServer.c +++ b/open-vm-tools/lib/hgfsServer/hgfsServer.c @@ -130,6 +130,39 @@ #define MAX_LOCKED_FILENODES 10 +struct HgfsTransportSessionInfo { + /* Default session id. */ + uint64 defaultSessionId; + + /* Lock to manipulate the list of sessions */ + MXUserExclLock *sessionArrayLock; + + /* List of sessions */ + DblLnkLst_Links sessionArray; + + /* Max packet size that is supported by both client and server. */ + uint32 maxPacketSize; + + /* Total number of sessions present this transport session*/ + uint32 numSessions; + + /* Transport session context. */ + void *transportData; + + /* Current state of the session. */ + HgfsSessionInfoState state; + + /* Session is dynamic or internal. */ + HgfsSessionInfoType type; + + /* Function callbacks into Hgfs Channels. */ + HgfsServerChannelCallbacks *channelCbTable; + + Atomic_uint32 refCount; /* Reference count for session. */ + + HgfsServerChannelData channelCapabilities; +}; + /* The input request paramaters object. */ typedef struct HgfsInputParam { const void *request; /* Hgfs header followed by operation request */ @@ -240,8 +273,21 @@ typedef struct HgfsSharedFolderProperties { Bool markedForDeletion; } HgfsSharedFolderProperties; -static void HgfsServerTransportRemoveSessionFromList(HgfsTransportSessionInfo *transportSession, - HgfsSessionInfo *sessionInfo); + +/* Allocate/Add sessions helper functions. */ + +static Bool +HgfsServerAllocateSession(HgfsTransportSessionInfo *transportSession, + HgfsSessionInfo **sessionData); +static HgfsInternalStatus +HgfsServerTransportAddSessionToList(HgfsTransportSessionInfo *transportSession, + HgfsSessionInfo *sessionInfo); +static void +HgfsServerTransportRemoveSessionFromList(HgfsTransportSessionInfo *transportSession, + HgfsSessionInfo *sessionInfo); +static HgfsSessionInfo * +HgfsServerTransportGetSessionInfo(HgfsTransportSessionInfo *transportSession, + uint64 sessionId); /* Local functions. */ static void HgfsInvalidateSessionObjects(DblLnkLst_Links *shares, @@ -347,7 +393,7 @@ static void HgfsServerRemoveDirNotifyWatch(HgfsInputParam *input); *---------------------------------------------------------------------------- */ -void +static void HgfsServerSessionGet(HgfsSessionInfo *session) // IN: session context { ASSERT(session); @@ -3276,7 +3322,7 @@ HgfsServerSessionReceive(HgfsPacket *packet, // IN: Hgfs Packet *----------------------------------------------------------------------------- */ -HgfsSessionInfo * +static HgfsSessionInfo * HgfsServerTransportGetSessionInfo(HgfsTransportSessionInfo *transportSession, // IN: transport session info uint64 sessionId) // IN: session id { @@ -3415,7 +3461,7 @@ HgfsServerTransportRemoveSessionFromList(HgfsTransportSessionInfo *transportSess *----------------------------------------------------------------------------- */ -HgfsInternalStatus +static HgfsInternalStatus HgfsServerTransportAddSessionToList(HgfsTransportSessionInfo *transportSession, // IN: transport session info HgfsSessionInfo *session) // IN: session info { @@ -4006,7 +4052,7 @@ HgfsServerSessionConnect(void *transportData, // IN: tra *----------------------------------------------------------------------------- */ -Bool +static Bool HgfsServerAllocateSession(HgfsTransportSessionInfo *transportSession, // IN: HgfsSessionInfo **sessionData) // OUT: { diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h index c66f0c8ef..a282a3784 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerInt.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerInt.h @@ -42,6 +42,7 @@ struct DirectoryEntry; #define HGFS_DEBUG_ASYNC (0) +typedef struct HgfsTransportSessionInfo HgfsTransportSessionInfo; /* Identifier for a local file */ typedef struct HgfsLocalId { @@ -247,39 +248,6 @@ typedef enum { HGFS_SESSION_STATE_CLOSED, } HgfsSessionInfoState; -typedef struct HgfsTransportSessionInfo { - /* Default session id. */ - uint64 defaultSessionId; - - /* Lock to manipulate the list of sessions */ - MXUserExclLock *sessionArrayLock; - - /* List of sessions */ - DblLnkLst_Links sessionArray; - - /* Max packet size that is supported by both client and server. */ - uint32 maxPacketSize; - - /* Total number of sessions present this transport session*/ - uint32 numSessions; - - /* Transport session context. */ - void *transportData; - - /* Current state of the session. */ - HgfsSessionInfoState state; - - /* Session is dynamic or internal. */ - HgfsSessionInfoType type; - - /* Function callbacks into Hgfs Channels. */ - HgfsServerChannelCallbacks *channelCbTable; - - Atomic_uint32 refCount; /* Reference count for session. */ - - HgfsServerChannelData channelCapabilities; -} HgfsTransportSessionInfo; - typedef struct HgfsSessionInfo { DblLnkLst_Links links; @@ -566,15 +534,6 @@ HgfsServerRestartSearchVirtualDir(HgfsGetNameFunc *getName, // IN: Name enum HgfsSessionInfo *session, // IN: Session info HgfsHandle searchHandle); // IN: search to restart -/* Allocate/Add sessions helper functions. */ - -Bool HgfsServerAllocateSession(HgfsTransportSessionInfo *transportSession, - HgfsSessionInfo **sessionData); - -void HgfsServerSessionGet(HgfsSessionInfo *session); - -HgfsInternalStatus HgfsServerTransportAddSessionToList(HgfsTransportSessionInfo *transportSession, - HgfsSessionInfo *sessionInfo); void * HgfsAllocInitReply(HgfsPacket *packet, // IN/OUT: Hgfs Packet @@ -685,10 +644,6 @@ HgfsServerGetTargetRelativePath(const char* source, // IN: source file name const char* target); // IN: target file name -/* Get the session with a specific session id */ -HgfsSessionInfo * -HgfsServerTransportGetSessionInfo(HgfsTransportSessionInfo *transportSession, // IN: transport session info - uint64 sessionId); // IN: session id Bool HgfsPacketSend(HgfsPacket *packet, // IN/OUT: Hgfs Packet diff --git a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h index bcfe8590e..91efcf579 100644 --- a/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h +++ b/open-vm-tools/lib/hgfsServer/hgfsServerParameters.h @@ -29,7 +29,7 @@ #include "hgfsServer.h" // for HgfsPacket type #include "hgfsProto.h" // for the HGFS protocol request, reply and types #include "hgfsUtil.h" // for HgfsInternalStatus -#include "hgfsServerInt.h" // for HgfsSessionInfo, HgfsInputParam, HgfsTransportSessionInfo +#include "hgfsServerInt.h" // for HgfsSessionInfo /*