]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: Clean up server packet abstraction part VII
authorVMware, Inc <>
Wed, 18 Sep 2013 03:17:19 +0000 (20:17 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:01:54 +0000 (22:01 -0700)
Consolidate the HgfsPacket bool fields into a flags field.
Make the names of the bool fields more accurate too in some cases.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/hgfsServer/hgfsServer.c
open-vm-tools/lib/hgfsServerManagerGuest/hgfsChannelGuestBd.c
open-vm-tools/lib/include/hgfsServer.h

index fc34c277d6e1302f33c3699bfa0f8df54b95732b..ebe09f3b6d08d7b8911d5a177c6d2a3aeffdd16c 100644 (file)
@@ -3254,10 +3254,11 @@ HgfsServerSessionReceive(HgfsPacket *packet,      // IN: Hgfs Packet
           (handlers[input->op].handler != NULL) &&
           (input->requestSize >= handlers[input->op].minReqSize)) {
          /* Initial validation passed, process the client request now. */
-         packet->processedAsync = (handlers[input->op].reqType == REQ_ASYNC) &&
-            (transportSession->channelCapabilities.flags & HGFS_CHANNEL_ASYNC);
-                                         ;
-         if (packet->processedAsync) {
+         if ((handlers[input->op].reqType == REQ_ASYNC) &&
+             (transportSession->channelCapabilities.flags & HGFS_CHANNEL_ASYNC)) {
+             packet->state |= HGFS_STATE_ASYNC_REQUEST;
+         }
+         if (0 != (packet->state & HGFS_STATE_ASYNC_REQUEST)) {
             LOG(4, ("%s: %d: @@Async\n", __FUNCTION__, __LINE__));
 #ifndef VMX86_TOOLS
             /*
@@ -4463,7 +4464,7 @@ HgfsServerSessionSendComplete(HgfsPacket *packet,   // IN/OUT: Hgfs packet
 {
    HgfsTransportSessionInfo *transportSession = clientData;
 
-   if (packet->guestInitiated) {
+   if (0 != (packet->state & HGFS_STATE_CLIENT_REQUEST)) {
       HSPU_PutMetaPacket(packet, transportSession->channelCbTable);
       HSPU_PutReplyPacket(packet, transportSession->channelCbTable);
       HSPU_PutDataPacketBuf(packet, transportSession->channelCbTable);
@@ -4575,7 +4576,8 @@ HgfsPacketSend(HgfsPacket *packet,            // IN/OUT: Hgfs Packet
                HgfsSendFlags flags)           // IN: flags for how to process
 {
    Bool result = FALSE;
-   Bool notificationNeeded = packet->guestInitiated && packet->processedAsync;
+   Bool notificationNeeded = (0 != (packet->state & HGFS_STATE_CLIENT_REQUEST) &&
+                              0 != (packet->state & HGFS_STATE_ASYNC_REQUEST));
 
    ASSERT(packet);
    ASSERT(transportSession);
@@ -8396,7 +8398,7 @@ HgfsServerDirWatchEvent(HgfsSharedFolderHandle sharedFolder, // IN: shared folde
 
    packetHeader = Util_SafeCalloc(1, sizeNeeded);
    packet = Util_SafeCalloc(1, sizeof *packet);
-   packet->guestInitiated = FALSE;
+   packet->state &= ~HGFS_STATE_CLIENT_REQUEST;
    packet->metaPacketSize = sizeNeeded;
    packet->metaPacket = packetHeader;
    packet->dataPacketIsAllocated = TRUE;
index ce49573d160dd82b79fa37bb7899d585fffce38b..fd3d0445eeb774994548bd23f033236afd9e01f4 100644 (file)
@@ -488,8 +488,7 @@ HgfsChannelGuestReceiveInternal(HgfsGuestConn *connData,  // IN: connection
    packet.metaPacketSize = packetInSize;
    packet.replyPacket = packetOut;
    packet.replyPacketSize = *packetOutSize;
-   /* Misnomer to be fixed, guestInitiated really means client initiated */
-   packet.guestInitiated = TRUE;
+   packet.state |= HGFS_STATE_CLIENT_REQUEST;
 
    /* The server will perform a synchronous processing of requests. */
    connData->serverCbTable->receive(&packet, connData->serverSession);
index 0786e133c6a616a9dd82bd720e05d1cf60ec25a0..a1c3510e6e80d310683cc4ed29bb7bee738edcc0 100644 (file)
@@ -49,15 +49,14 @@ typedef enum {
    BUF_READWRITEABLE, /* Establish read-writeable mappings */
 } MappingType;
 
+typedef uint64 HgfsStateFlags;
+#define HGFS_STATE_CLIENT_REQUEST         (1 << 0)
+#define HGFS_STATE_ASYNC_REQUEST          (1 << 1)
 typedef
 struct HgfsPacket {
    uint64 id;
 
-   /* Does transport need to send Async reply ? */
-   Bool processedAsync;
-
-   /* Is the packet guest initiated ? */
-   Bool guestInitiated;
+   HgfsStateFlags state;
 
    /* For metapacket we always establish writeable mappings */
    void *metaPacket;