]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Removed Descriptor-related code used for testing fd passing via UDS messages.
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 5 Jul 2010 21:28:23 +0000 (15:28 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Mon, 5 Jul 2010 21:28:23 +0000 (15:28 -0600)
src/ipc/Coordinator.cc
src/ipc/Coordinator.h
src/ipc/Messages.cc
src/ipc/Messages.h
src/ipc/Strand.cc

index f1d414c80a8682f29a6abec29e3f5a7356e7c7e9..47ecf7ccfd4f563dd328067d14e22b58a82e947f 100644 (file)
@@ -58,11 +58,6 @@ void Ipc::Coordinator::receive(const TypedMsgHdr& message)
         handleSharedListenRequest(SharedListenRequest(message));
         break;
 
-    case mtDescriptorGet:
-        debugs(54, 6, HERE << "Descriptor get request");
-        handleDescriptorGet(Descriptor(message));
-        break;
-
     default:
         debugs(54, 1, HERE << "Unhandled message type: " << message.type());
         break;
@@ -123,34 +118,6 @@ Ipc::Coordinator::openListenSocket(const SharedListenRequest& request,
     return sock;
 }
 
-void Ipc::Coordinator::handleDescriptorGet(const Descriptor& request)
-{
-    // XXX: hack: create descriptor here
-    char buffer[64];
-    snprintf(buffer, sizeof(buffer), "/tmp/squid_shared_file.txt");
-    static int fd = -1;
-    if (fd < 0) {
-        fd = open(buffer, O_CREAT | O_RDWR | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
-        int n = snprintf(buffer, sizeof(buffer), "coord: created %d\n", fd);
-        ssize_t bytes = write(fd, buffer, n);
-        Must(bytes == n);
-        debugs(54, 6, "Created FD " << fd << " for kid" << request.fromKid);
-    } else {
-        int n = snprintf(buffer, sizeof(buffer), "coord: updated %d\n", fd);
-        ssize_t bytes = write(fd, buffer, n);
-        Must(bytes == n);
-    }
-
-    debugs(54, 6, "Sending FD " << fd << " to kid" << request.fromKid);
-
-    Descriptor response(-1, fd);
-    TypedMsgHdr message;
-    response.pack(message);
-    SendMessage(MakeAddr(strandAddrPfx, request.fromKid), message);
-
-    // XXX: close(fd); fd should be opened until the message has not reached rec iver 
-}
-
 void Ipc::Coordinator::broadcastSignal(int sig) const
 {
     typedef Strands::const_iterator SCI;
index 716caed055ed2686017f9f38bad3ccc30be116f2..f508205eb0c33c97a6f1203b5a92e56316bc1378 100644 (file)
@@ -39,7 +39,6 @@ protected:
 
     /// returns cached socket or calls openListenSocket()
     void handleSharedListenRequest(const SharedListenRequest& request);
-    void handleDescriptorGet(const Descriptor& request);
 
     /// calls comm_open_listener()
     int openListenSocket(const SharedListenRequest& request, int &errNo);
index 99d9d9dd89521b7734499449f4b1f64dce197dab..5526db7fed16d0e06b7071f6db00b27471d828f0 100644 (file)
@@ -7,7 +7,6 @@
 
 
 #include "config.h"
-#include "comm.h"
 #include "ipc/Messages.h"
 #include "ipc/TypedMsgHdr.h"
 
@@ -29,33 +28,3 @@ void Ipc::StrandCoord::pack(TypedMsgHdr &hdrMsg) const
 {
     hdrMsg.putData(mtRegistration, this, sizeof(*this));
 }
-
-
-Ipc::Descriptor::Descriptor(): fromKid(-1), fd(-1)
-{
-}
-
-Ipc::Descriptor::Descriptor(int aFromKid, int aFd): fromKid(aFromKid), fd(aFd)
-{
-}
-
-Ipc::Descriptor::Descriptor(const TypedMsgHdr &hdrMsg): fromKid(-1), fd(-1)
-{
-    if (hdrMsg.type() == mtDescriptorGet) {
-        hdrMsg.getData(mtDescriptorGet, this, sizeof(*this));
-        fd = -1;
-    } else {
-        hdrMsg.getData(mtDescriptorPut, this, sizeof(*this));
-        fd = hdrMsg.getFd();
-    }
-}
-
-void Ipc::Descriptor::pack(TypedMsgHdr &hdrMsg) const
-{
-    if (fd >= 0) {
-        hdrMsg.putData(mtDescriptorPut, this, sizeof(*this));
-        hdrMsg.putFd(fd);
-    } else {
-        hdrMsg.putData(mtDescriptorGet, this, sizeof(*this));
-    }
-}
index 31cb6cb1658aa9534d15ce5fafb7538f42eb2b4b..7ece20418dcdbd51702d686d7d066ee15d3f3ac5 100644 (file)
@@ -9,19 +9,17 @@
 #define SQUID_IPC_MESSAGES_H
 
 #include <sys/types.h>
-#include <sys/socket.h>
 
-/// Declare IPC messages. These classes translate between high-level
-/// information and low-level TypedMsgHdr (i.e., struct msghdr) buffers.
+/** Declarations used by varios IPC messages */
 
 namespace Ipc
 {
 
 class TypedMsgHdr;
 
+/// message class identifier
 typedef enum { mtNone = 0, mtRegistration,
-    mtSharedListenRequest, mtSharedListenResponse,
-    mtDescriptorGet, mtDescriptorPut } MessageType;
+    mtSharedListenRequest, mtSharedListenResponse } MessageType;
 
 /// Strand location details
 class StrandCoord {
@@ -36,21 +34,6 @@ public:
     pid_t pid; ///< OS process or thread identifier
 };
 
-/// a [socket] descriptor information
-class Descriptor
-{
-public:
-    Descriptor(); ///< unknown descriptor
-    Descriptor(int fromKid, int fd); ///< from descriptor sender or requestor
-    explicit Descriptor(const TypedMsgHdr &hdrMsg); ///< from recvmsg()
-    void pack(TypedMsgHdr &hdrMsg) const; ///< prepare for sendmsg()
-
-public:
-    int fromKid; /// the source of this message
-    int fd; ///< raw descriptor value
-};
-
-
 } // namespace Ipc;
 
 
index c8f2c4119cc322fe16741145cb369e02b606f1cf..cc0bd841c26e391ac25b128c1567db80fff347a9 100644 (file)
@@ -50,10 +50,6 @@ void Ipc::Strand::receive(const TypedMsgHdr &message)
         SharedListenJoined(SharedListenResponse(message));
         break;
 
-    case mtDescriptorPut:
-        putDescriptor(Descriptor(message));
-        break;
-
     default:
         debugs(54, 1, HERE << "Unhandled message type: " << message.type());
         break;
@@ -66,12 +62,6 @@ void Ipc::Strand::handleRegistrationResponse(const StrandCoord &strand)
     if (strand.kidId == KidIdentifier && strand.pid == getpid()) {
         debugs(54, 6, "kid" << KidIdentifier << " registered");
         clearTimeout(); // we are done
-
-        debugs(54, 6, HERE << "requesting FD");
-        Descriptor request(KidIdentifier, -1);
-        TypedMsgHdr message;
-        request.pack(message);
-        SendMessage(coordinatorAddr, message);
     } else {
         // could be an ACK to the registration message of our dead predecessor
         debugs(54, 6, "kid" << KidIdentifier << " is not yet registered");
@@ -79,16 +69,6 @@ void Ipc::Strand::handleRegistrationResponse(const StrandCoord &strand)
     }
 }
 
-/// receive descriptor we asked for
-void Ipc::Strand::putDescriptor(const Descriptor &message)
-{
-    debugs(54, 6, HERE << "got FD " << message.fd);
-    char buffer[64];
-    const int n = snprintf(buffer, sizeof(buffer), "strand: kid%d wrote using FD %d\n", KidIdentifier, message.fd);
-    ssize_t bytes = write(message.fd, buffer, n);
-    Must(bytes == n);
-}
-
 void Ipc::Strand::timedout()
 {
     debugs(54, 6, HERE << isRegistered);