Skip to content

Commit

Permalink
How about we try not sending to all clients on a bridge from deep wit…
Browse files Browse the repository at this point in the history
…hin per-client routines

If we send to all clients on a bridge from within per-client routines, traffic scales
as the square of the number of clients, which is not good, to put it mildly. (wtf was
I thinking?)

Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
  • Loading branch information
smcameron committed Jun 17, 2018
1 parent de348a2 commit 2d595e2
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions snis_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -13136,9 +13136,7 @@ static void pack_and_send_ship_sdata_packet(struct game_client *c, struct snis_e
p.lifeform_count = o->tsd.starbase.lifeform_count;
else
p.lifeform_count = 0;
pthread_mutex_unlock(&universe_mutex);
send_ship_sdata_packet(c, &p);
pthread_mutex_lock(&universe_mutex);
}

static void send_update_ship_cargo_info(struct game_client *c, struct snis_entity *o)
Expand Down Expand Up @@ -13179,9 +13177,7 @@ static void send_update_ship_cargo_info(struct game_client *c, struct snis_entit
qty = cbc->qty;
packed_buffer_append(pb, "bwS", (uint8_t) i, item, qty, (int32_t) 1000000);
}
pthread_mutex_unlock(&universe_mutex);
send_packet_to_all_clients_on_a_bridge(c->shipid, pb, ROLE_SCIENCE);
pthread_mutex_lock(&universe_mutex);
pb_queue_to_client(c, pb);
}

static int save_sdata_bandwidth(void)
Expand Down Expand Up @@ -19672,7 +19668,7 @@ static void send_ship_sdata_packet(struct game_client *c, struct ship_sdata_pack
sip->shield_strength, sip->shield_wavelength, sip->shield_width, sip->shield_depth,
sip->faction, sip->lifeform_count,
sip->name, (unsigned short) sizeof(sip->name));
send_packet_to_all_clients_on_a_bridge(c->shipid, pb, ROLE_ALL);
pb_queue_to_client(c, pb);
}

static void send_generic_ship_damage_packet(struct snis_entity *o, uint8_t opcode)
Expand Down

0 comments on commit 2d595e2

Please sign in to comment.