Force-free all open connections on close

This commit is contained in:
mjentsch 2014-10-10 17:26:31 +02:00
parent 2bebb7ab62
commit 61c8735578
4 changed files with 5 additions and 19 deletions

View file

@ -1915,7 +1915,7 @@ void mtproto_close_foreign (struct telegram *instance)
/**
* Free all destroyed connections
*/
void mtproto_free_closed (struct telegram *tg) {
void mtproto_free_closed (struct telegram *tg, int force) {
int i;
for (i = 0; i < 100; i++) {
if (tg->Cs[i] == NULL) continue;
@ -1923,7 +1923,7 @@ void mtproto_free_closed (struct telegram *tg) {
debug ("checking mtproto_connection %d: c_state:%d destroy:%d, quries_num:%d\n",
i, c->c_state, c->destroy, c->queries_num);
if (c->destroy == 0) continue;
if (c->connection->out_bytes > 0) {
if (!force && c->connection->out_bytes > 0) {
debug ("still %d bytes ouput left, skipping connection...\n", c->connection->out_bytes);
continue;
}

View file

@ -508,7 +508,7 @@ static inline void hexdump_out (struct mtproto_connection *self) {
void my_clock_gettime (int clock_id, struct timespec *T);
void mtproto_close_foreign (struct telegram *instance);
void mtproto_free_closed (struct telegram *tg);
void mtproto_free_closed (struct telegram *tg, int force);
#endif

View file

@ -213,21 +213,7 @@ static void tgprpl_input_cb(gpointer data, gint source, PurpleInputCondition con
telegram_flush (conn->mtp->instance);
// free all mtproto_connections that may have errored
mtproto_free_closed(conn->mtp->instance);
}
}
/**
* Telegram announced that it awaits new input from the read-handle
* TODO: this is currently unused, evaluate wether its needed at all
*/
static void tgprpl_has_input(void *handle)
{
debug("tgprpl_has_input()\n");
mtproto_handle *conn = handle;
if (! conn->rh) {
conn->rh = purple_input_add(conn->fd, PURPLE_INPUT_READ, tgprpl_input_cb, handle);
debug("Attached read handle: %u ", conn->rh);
mtproto_free_closed(conn->mtp->instance, 0);
}
}

View file

@ -193,7 +193,7 @@ void telegram_destroy(struct telegram *this)
}
free_queries (this);
free_timers (this);
mtproto_free_closed (this);
mtproto_free_closed (this, 1);
free_bl (this->bl);
free_auth (this->auth.DC_list, 11);