Keep track of client's pid
This commit is contained in:
@@ -143,6 +143,7 @@ struct Client
|
||||
bool has_epollout { false };
|
||||
bool has_bigrequests { false };
|
||||
CARD16 sequence { 0 };
|
||||
BAN::Optional<uint32_t> pid;
|
||||
BAN::Vector<uint8_t> input_buffer;
|
||||
BAN::Vector<uint8_t> output_buffer;
|
||||
BAN::HashSet<CARD32> objects;
|
||||
|
||||
@@ -391,11 +391,21 @@ int main()
|
||||
continue;
|
||||
}
|
||||
|
||||
BAN::Optional<uint32_t> client_pid;
|
||||
|
||||
#ifdef SO_PEERCRED
|
||||
ucred client_cred;
|
||||
socklen_t client_cred_len = sizeof(client_cred);
|
||||
if (getsockopt(client_sock, SOL_SOCKET, SO_PEERCRED, &client_cred, &client_cred_len) == 0)
|
||||
client_pid = client_cred.pid;
|
||||
#endif
|
||||
|
||||
MUST(g_epoll_thingies.insert(client_sock, {
|
||||
.type = EpollThingy::Type::Client,
|
||||
.value = Client {
|
||||
.fd = client_sock,
|
||||
.state = Client::State::ConnectionSetup,
|
||||
.pid = client_pid,
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user