mirror of https://github.com/schoebel/mars
infra: {send,recv}ing mars_cmd via wrapper
This commit is contained in:
parent
381b6489f6
commit
0c5b5daa38
|
@ -299,7 +299,7 @@ struct client_channel *_get_channel(struct client_bundle *bundle, int min_channe
|
|||
.cmd_code = CMD_CONNECT,
|
||||
.cmd_str1 = bundle->path,
|
||||
};
|
||||
int status = mars_send_struct(&res->socket, &cmd, mars_cmd_meta, false);
|
||||
int status = mars_send_cmd(&res->socket, &cmd, false);
|
||||
MARS_DBG("send CMD_CONNECT status = %d\n", status);
|
||||
if (unlikely(status < 0)) {
|
||||
MARS_WRN("connect '%s' @%s on channel %d failed, status = %d\n",
|
||||
|
@ -330,7 +330,7 @@ int _request_info(struct client_channel *ch)
|
|||
int status;
|
||||
|
||||
MARS_DBG("\n");
|
||||
status = mars_send_struct(&ch->socket, &cmd, mars_cmd_meta, false);
|
||||
status = mars_send_cmd(&ch->socket, &cmd, false);
|
||||
MARS_DBG("send CMD_GETINFO status = %d\n", status);
|
||||
if (unlikely(status < 0)) {
|
||||
MARS_DBG("send of getinfo failed, status = %d\n", status);
|
||||
|
@ -553,7 +553,7 @@ int receiver_thread(void *data)
|
|||
continue;
|
||||
}
|
||||
|
||||
status = mars_recv_struct(&ch->socket, &cmd, mars_cmd_meta);
|
||||
status = mars_recv_cmd(&ch->socket, &cmd);
|
||||
MARS_IO("got cmd = %d status = %d\n", cmd.cmd_code, status);
|
||||
if (status <= 0) {
|
||||
if (brick->power.button &&
|
||||
|
|
|
@ -1186,8 +1186,22 @@ const struct meta mars_cmd_meta[] = {
|
|||
META_INI(cmd_str1, struct mars_cmd, FIELD_STRING),
|
||||
{}
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mars_cmd_meta);
|
||||
|
||||
int mars_send_cmd(struct mars_socket *msock, struct mars_cmd *cmd, bool cork)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = desc_send_struct(msock, cmd, mars_cmd_meta, cork);
|
||||
return status;
|
||||
}
|
||||
|
||||
int _mars_recv_cmd(struct mars_socket *msock, struct mars_cmd *cmd, int line)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = desc_recv_struct(msock, cmd, mars_cmd_meta, line);
|
||||
return status;
|
||||
}
|
||||
|
||||
int mars_send_mref(struct mars_socket *msock, struct mref_object *mref, bool cork)
|
||||
{
|
||||
|
@ -1204,7 +1218,7 @@ int mars_send_mref(struct mars_socket *msock, struct mref_object *mref, bool cor
|
|||
if (!cork || !msock->s_pos)
|
||||
get_lamport(NULL, &cmd.cmd_stamp);
|
||||
|
||||
status = desc_send_struct(msock, &cmd, mars_cmd_meta, true);
|
||||
status = mars_send_cmd(msock, &cmd, true);
|
||||
if (status < 0)
|
||||
goto done;
|
||||
|
||||
|
@ -1263,7 +1277,7 @@ int mars_send_cb(struct mars_socket *msock, struct mref_object *mref, bool cork)
|
|||
if (!cork || !msock->s_pos)
|
||||
get_lamport(NULL, &cmd.cmd_stamp);
|
||||
|
||||
status = desc_send_struct(msock, &cmd, mars_cmd_meta, true);
|
||||
status = mars_send_cmd(msock, &cmd, true);
|
||||
if (status < 0)
|
||||
goto done;
|
||||
|
||||
|
|
|
@ -119,8 +119,6 @@ struct mars_cmd {
|
|||
//char *cmd_str3;
|
||||
};
|
||||
|
||||
extern const struct meta mars_cmd_meta[];
|
||||
|
||||
extern char *(*mars_translate_hostname)(const char *name);
|
||||
|
||||
/* Low-level network traffic
|
||||
|
@ -154,6 +152,14 @@ extern int _mars_recv_struct(struct mars_socket *msock, void *data, const struct
|
|||
|
||||
/* High-level transport of mars structures
|
||||
*/
|
||||
|
||||
extern int mars_send_cmd(struct mars_socket *msock, struct mars_cmd *cmd, bool cork);
|
||||
extern int _mars_recv_cmd(struct mars_socket *msock, struct mars_cmd *cmd, int line);
|
||||
#define mars_recv_cmd(_sock_,_cmd_) \
|
||||
({ \
|
||||
_mars_recv_cmd(_sock_, _cmd_, __LINE__); \
|
||||
})
|
||||
|
||||
extern int mars_send_dent_list(struct mars_socket *msock, struct list_head *anchor);
|
||||
extern int mars_recv_dent_list(struct mars_socket *msock, struct list_head *anchor);
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ int handler_thread(void *data)
|
|||
goto clean;
|
||||
}
|
||||
|
||||
status = mars_recv_struct(sock, &cmd, mars_cmd_meta);
|
||||
status = mars_recv_cmd(sock, &cmd);
|
||||
if (unlikely(status < 0)) {
|
||||
MARS_WRN("#%d recv cmd status = %d\n", sock->s_debug_nr, status);
|
||||
goto clean_unlock;
|
||||
|
@ -476,7 +476,7 @@ int handler_thread(void *data)
|
|||
break;
|
||||
}
|
||||
down(&brick->socket_sem);
|
||||
status = mars_send_struct(sock, &cmd, mars_cmd_meta, true);
|
||||
status = mars_send_cmd(sock, &cmd, true);
|
||||
if (status >= 0) {
|
||||
status = mars_send_struct(sock, &info, mars_info_meta, false);
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ int handler_thread(void *data)
|
|||
err:
|
||||
cmd.cmd_int1 = status;
|
||||
down(&brick->socket_sem);
|
||||
status = mars_send_struct(sock, &cmd, mars_cmd_meta, false);
|
||||
status = mars_send_cmd(sock, &cmd, false);
|
||||
up(&brick->socket_sem);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2499,7 +2499,7 @@ int peer_thread(void *data)
|
|||
pause_time = 0;
|
||||
MARS_DBG("sending notify to peer...\n");
|
||||
cmd.cmd_code = CMD_NOTIFY;
|
||||
status = mars_send_struct(&peer->socket, &cmd, mars_cmd_meta, true);
|
||||
status = mars_send_cmd(&peer->socket, &cmd, true);
|
||||
}
|
||||
|
||||
if (likely(status >= 0)) {
|
||||
|
@ -2522,7 +2522,7 @@ int peer_thread(void *data)
|
|||
}
|
||||
MARS_DBG("fetching dents from '%s' paths '%s'\n",
|
||||
peer->peer, cmd.cmd_str1);
|
||||
status = mars_send_struct(&peer->socket, &cmd, mars_cmd_meta, false);
|
||||
status = mars_send_cmd(&peer->socket, &cmd, false);
|
||||
}
|
||||
if (unlikely(status < 0)) {
|
||||
MARS_WRN("communication error on send, status = %d\n", status);
|
||||
|
|
Loading…
Reference in New Issue