From 21a94d447c19a63ff53ce390b1eebe7051adea01 Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Thu, 13 Aug 2026 22:09:54 +0900 Subject: [PATCH] server: remove client ownership wrapper --- srv.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/srv.c b/srv.c index acb4255..9688029 100644 --- a/srv.c +++ b/srv.c @@ -7,12 +7,6 @@ static char adir[256]; static Channel *clientc; -typedef struct Client Client; -struct Client -{ - int fd; -}; - static int srvreadkey(int fd, Keyreq *kr) { @@ -33,7 +27,6 @@ srvreadkey(int fd, Keyreq *kr) static void clientthread(void *arg) { - Client *client; Channel *reply; int fd; Keyreq kr; @@ -43,12 +36,11 @@ clientthread(void *arg) int n, ncommit, npreedit, want; uchar token; - client = arg; - fd = client->fd; + fd = (int)(uintptr)arg; threadsetname("client %d", fd); reply = chancreate(sizeof(Keyres), 0); kr.reply = reply; - kr.owner = client; + kr.owner = &fd; while((want = srvreadkey(fd, &kr)) >= 0){ chansend(keyc, &kr); chanrecv(reply, &res); @@ -64,7 +56,6 @@ clientthread(void *arg) chanrecv(reply, &res); chanfree(reply); close(fd); - free(client); chanrecv(clientc, &token); } @@ -88,7 +79,6 @@ srvinit(void) void srvthread(void*) { - Client *client; char ldir[40]; int fd; uchar token; @@ -105,12 +95,9 @@ srvthread(void*) close(fd); continue; } - client = emalloc(sizeof *client); - client->fd = fd; - if(proccreate(clientthread, client, 8192) < 0){ + if(proccreate(clientthread, (void*)(uintptr)fd, 8192) < 0){ chanrecv(clientc, &token); close(fd); - free(client); } } }