Add support for better pipelining of commands, in order to reduce the number of send() calls.

This commit is contained in:
Jan Vidar Krey 2009-07-25 03:54:59 +02:00
parent bb27ff617c
commit e281f61472
4 changed files with 23 additions and 3 deletions

View File

@ -312,9 +312,11 @@ void hub_send_hubinfo(struct hub_info* hub, struct user* u)
void hub_send_handshake(struct hub_info* hub, struct user* u)
{
user_flag_set(u, flag_pipeline);
hub_send_support(hub, u);
hub_send_sid(hub, u);
hub_send_hubinfo(hub, u);
route_flush_pipeline(hub, u);
if (!user_is_disconnecting(u))
{

View File

@ -97,7 +97,7 @@ int route_to_user(struct hub_info* hub, struct user* user, struct adc_message* m
free(data);
#endif
if (hub_sendq_is_empty(user->net.send_queue))
if (hub_sendq_is_empty(user->net.send_queue) && !user_flag_get(user, flag_pipeline))
{
/* Perform oportunistic write */
hub_sendq_add(user->net.send_queue, msg);
@ -108,12 +108,24 @@ int route_to_user(struct hub_info* hub, struct user* user, struct adc_message* m
if (check_send_queue(hub, user, msg) >= 0)
{
hub_sendq_add(user->net.send_queue, msg);
user_net_io_want_write(user);
if (!user_flag_get(user, flag_pipeline))
user_net_io_want_write(user);
}
}
return 1;
}
int route_flush_pipeline(struct hub_info* hub, struct user* u)
{
if (hub_sendq_is_empty(u->net.send_queue))
return 0;
handle_net_write(u);
user_flag_unset(u, flag_pipeline);
return 1;
}
int route_to_all(struct hub_info* hub, struct adc_message* command) /* iterate users */
{
struct user* user = (struct user*) list_get_first(hub->users->list);

View File

@ -25,6 +25,11 @@
*/
extern int route_message(struct hub_info* hub, struct user* u, struct adc_message* msg);
/**
* Send queued messages.
*/
extern int route_flush_pipeline(struct hub_info* hub, struct user* u);
/**
* Transmit message directly to one user.
*/

View File

@ -50,7 +50,8 @@ enum user_flags
flag_want_read = 0x08000000, /** Need to read (SSL) */
flag_want_write = 0x10000000, /** Need to write (SSL) */
flag_user_list = 0x20000000, /** Send queue bypass (when receiving the send queue) */
flag_nat = 0x40000000, /** nat override enabled */
flag_pipeline = 0x40000000, /** Hub message pipelining */
flag_nat = 0x80000000, /** nat override enabled */
};
enum user_quit_reason