mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-23 21:35:29 +03:00
Tidy the socket callbacks so that all the work is done outside the
main loop.
This commit is contained in:
parent
09654d7dd8
commit
2affe53727
@ -202,7 +202,7 @@ static void process_oob_msg(char *buf, int len, int nodeid)
|
||||
}
|
||||
}
|
||||
|
||||
int cluster_fd_callback(struct local_client *fd, char *buf, int len, char *csid,
|
||||
int cluster_fd_callback(struct local_client *client, char *buf, int len, char *csid,
|
||||
struct local_client **new_client)
|
||||
{
|
||||
struct iovec iov[2];
|
||||
@ -246,7 +246,11 @@ int cluster_fd_callback(struct local_client *fd, char *buf, int len, char *csid,
|
||||
len = -1;
|
||||
errno = EAGAIN;
|
||||
}
|
||||
memcpy(csid, &saddr.scl_nodeid, sizeof(saddr.scl_nodeid));
|
||||
else {
|
||||
memcpy(csid, &saddr.scl_nodeid, sizeof(saddr.scl_nodeid));
|
||||
/* Send it back to clvmd */
|
||||
process_message(client, buf, len, csid);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,6 @@ static void main_loop(int local_sock, int cmd_timeout)
|
||||
|
||||
if ((select_status = select(FD_SETSIZE, &in, NULL, NULL, &tv)) > 0) {
|
||||
struct local_client *lastfd = NULL;
|
||||
struct clvm_header *inheader;
|
||||
char csid[MAX_CSID_LEN];
|
||||
char buf[MAX_CLUSTER_MESSAGE];
|
||||
|
||||
@ -514,9 +513,8 @@ static void main_loop(int local_sock, int cmd_timeout)
|
||||
type == CLUSTER_INTERNAL)
|
||||
goto closedown;
|
||||
|
||||
DEBUGLOG
|
||||
("ret == %d, errno = %d. removing client\n",
|
||||
ret, errno);
|
||||
DEBUGLOG("ret == %d, errno = %d. removing client\n",
|
||||
ret, errno);
|
||||
lastfd->next = thisfd->next;
|
||||
free_fd = thisfd;
|
||||
thisfd = lastfd;
|
||||
@ -531,33 +529,6 @@ static void main_loop(int local_sock, int cmd_timeout)
|
||||
thisfd->next = newfd;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (thisfd->type) {
|
||||
case CLUSTER_MAIN_SOCK:
|
||||
case CLUSTER_DATA_SOCK:
|
||||
inheader =
|
||||
(struct clvm_header *) buf;
|
||||
ntoh_clvm(inheader); /* Byteswap fields */
|
||||
if (inheader->cmd ==
|
||||
CLVMD_CMD_REPLY)
|
||||
process_reply
|
||||
(inheader, ret,
|
||||
csid);
|
||||
else
|
||||
add_to_lvmqueue(thisfd,
|
||||
inheader,
|
||||
ret,
|
||||
csid);
|
||||
break;
|
||||
|
||||
/* All the work for these is done in the callback
|
||||
rightly or wrongly... */
|
||||
case LOCAL_RENDEZVOUS:
|
||||
case LOCAL_SOCK:
|
||||
case THREAD_PIPE:
|
||||
case CLUSTER_INTERNAL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
lastfd = thisfd;
|
||||
}
|
||||
@ -1697,6 +1668,19 @@ static int open_local_sock()
|
||||
return local_socket;
|
||||
}
|
||||
|
||||
void process_message(struct local_client *client, char *buf, int len, char *csid)
|
||||
{
|
||||
struct clvm_header *inheader;
|
||||
|
||||
inheader = (struct clvm_header *) buf;
|
||||
ntoh_clvm(inheader); /* Byteswap fields */
|
||||
if (inheader->cmd == CLVMD_CMD_REPLY)
|
||||
process_reply(inheader, len, csid);
|
||||
else
|
||||
add_to_lvmqueue(client, inheader, len, csid);
|
||||
}
|
||||
|
||||
|
||||
static void check_all_callback(struct local_client *client, char *csid,
|
||||
int node_up)
|
||||
{
|
||||
|
@ -115,5 +115,5 @@ extern void cmd_client_cleanup(struct local_client *client);
|
||||
extern int add_client(struct local_client *new_client);
|
||||
|
||||
extern void clvmd_cluster_init_completed(void);
|
||||
|
||||
extern void process_message(struct local_client *client, char *buf, int len, char *csid);
|
||||
#endif
|
||||
|
@ -258,6 +258,10 @@ static int read_from_tcpsock(struct local_client *client, char *buf, int len, ch
|
||||
/* Tell cluster manager layer */
|
||||
add_down_node(remcsid);
|
||||
}
|
||||
else {
|
||||
/* Send it back to clvmd */
|
||||
process_message(client, buf, len, csid);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user