Force-free all open connections on close
This commit is contained in:
parent
2bebb7ab62
commit
61c8735578
4 changed files with 5 additions and 19 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue