export the function client_is_expired()
Instead of passing the pointer to the "expired" flag to processListOfCommands(), this function should use the client API to check this flag. We can now remove the "global_expired" hack introduced recently.
This commit is contained in:
@@ -129,21 +129,17 @@ static void set_send_buf_size(struct client *client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int client_is_expired(const struct client *client)
|
int client_is_expired(const struct client *client)
|
||||||
{
|
{
|
||||||
return client->fd < 0;
|
return client->fd < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int global_expired;
|
|
||||||
|
|
||||||
static inline void client_set_expired(struct client *client)
|
static inline void client_set_expired(struct client *client)
|
||||||
{
|
{
|
||||||
if (client->fd >= 0) {
|
if (client->fd >= 0) {
|
||||||
xclose(client->fd);
|
xclose(client->fd);
|
||||||
client->fd = -1;
|
client->fd = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
global_expired = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void client_init(struct client *client, int fd)
|
static void client_init(struct client *client, int fd)
|
||||||
@@ -341,11 +337,8 @@ static int client_process_line(struct client *client)
|
|||||||
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
|
if (strcmp(line, CLIENT_LIST_MODE_END) == 0) {
|
||||||
DEBUG("client %i: process command "
|
DEBUG("client %i: process command "
|
||||||
"list\n", client->num);
|
"list\n", client->num);
|
||||||
|
|
||||||
global_expired = 0;
|
|
||||||
ret = processListOfCommands(client,
|
ret = processListOfCommands(client,
|
||||||
&(client->permission),
|
&(client->permission),
|
||||||
&global_expired,
|
|
||||||
client->cmd_list_OK,
|
client->cmd_list_OK,
|
||||||
client->cmd_list);
|
client->cmd_list);
|
||||||
DEBUG("client %i: process command "
|
DEBUG("client %i: process command "
|
||||||
|
@@ -37,6 +37,8 @@ void client_new(int fd, const struct sockaddr *addr);
|
|||||||
*/
|
*/
|
||||||
int client_get_fd(struct client *client);
|
int client_get_fd(struct client *client);
|
||||||
|
|
||||||
|
int client_is_expired(const struct client *client);
|
||||||
|
|
||||||
int client_print(int fd, const char *buffer, size_t len);
|
int client_print(int fd, const char *buffer, size_t len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1235,7 +1235,7 @@ static int processCommandInternal(struct client *client,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int processListOfCommands(struct client *client, int *permission, int *expired,
|
int processListOfCommands(struct client *client, int *permission,
|
||||||
int listOK, struct strnode *list)
|
int listOK, struct strnode *list)
|
||||||
{
|
{
|
||||||
int fd = client_get_fd(client);
|
int fd = client_get_fd(client);
|
||||||
@@ -1249,7 +1249,7 @@ int processListOfCommands(struct client *client, int *permission, int *expired,
|
|||||||
cur->data);
|
cur->data);
|
||||||
ret = processCommandInternal(client, permission, cur->data, cur);
|
ret = processCommandInternal(client, permission, cur->data, cur);
|
||||||
DEBUG("processListOfCommands: command returned %i\n", ret);
|
DEBUG("processListOfCommands: command returned %i\n", ret);
|
||||||
if (ret != 0 || (*expired) != 0)
|
if (ret != 0 || client_is_expired(client))
|
||||||
goto out;
|
goto out;
|
||||||
else if (listOK)
|
else if (listOK)
|
||||||
fdprintf(fd, "list_OK\n");
|
fdprintf(fd, "list_OK\n");
|
||||||
|
@@ -29,8 +29,7 @@
|
|||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
|
|
||||||
int processListOfCommands(struct client *client,
|
int processListOfCommands(struct client *client, int *permission,
|
||||||
int *permission, int *expired,
|
|
||||||
int listOK, struct strnode *list);
|
int listOK, struct strnode *list);
|
||||||
|
|
||||||
int processCommand(struct client *client,
|
int processCommand(struct client *client,
|
||||||
|
Reference in New Issue
Block a user