server: remove client ownership wrapper
This commit is contained in:
19
srv.c
19
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user