| 1196 /* Destroy session if fatal. */ |
1196 /* Destroy session if fatal. */ |
| 1197 if (msim_msg_get(msg, "fatal")) |
1197 if (msim_msg_get(msg, "fatal")) |
| 1198 { |
1198 { |
| 1199 purple_debug_info("msim", "fatal error, closing\n"); |
1199 purple_debug_info("msim", "fatal error, closing\n"); |
| 1200 purple_connection_error(session->gc, full_errmsg); |
1200 purple_connection_error(session->gc, full_errmsg); |
| 1201 close(session->fd); |
1201 |
| 1202 /* Do not call msim_session_destroy(session) - called in msim_close(). */ |
1202 msim_close(session->gc); |
| 1203 } |
1203 } |
| 1204 |
1204 |
| 1205 return TRUE; |
1205 return TRUE; |
| 1206 } |
1206 } |
| 1207 |
1207 |
| 1634 gc = (PurpleConnection *)(gc_uncasted); |
1634 gc = (PurpleConnection *)(gc_uncasted); |
| 1635 account = purple_connection_get_account(gc); |
1635 account = purple_connection_get_account(gc); |
| 1636 session = gc->proto_data; |
1636 session = gc->proto_data; |
| 1637 |
1637 |
| 1638 g_return_if_fail(cond == PURPLE_INPUT_READ); |
1638 g_return_if_fail(cond == PURPLE_INPUT_READ); |
| 1639 /* TODO: fix bug #193, crash when re-login */ |
|
| 1640 g_return_if_fail(MSIM_SESSION_VALID(session)); |
1639 g_return_if_fail(MSIM_SESSION_VALID(session)); |
| 1641 |
1640 |
| 1642 /* Only can handle so much data at once... |
1641 /* Only can handle so much data at once... |
| 1643 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
1642 * If this happens, try recompiling with a higher MSIM_READ_BUF_SIZE. |
| 1644 * Should be large enough to hold the largest protocol message. |
1643 * Should be large enough to hold the largest protocol message. |
| 1647 { |
1646 { |
| 1648 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
1647 purple_debug_error("msim", "msim_input_cb: %d-byte read buffer full!\n", |
| 1649 MSIM_READ_BUF_SIZE); |
1648 MSIM_READ_BUF_SIZE); |
| 1650 purple_connection_error(gc, _("Read buffer full")); |
1649 purple_connection_error(gc, _("Read buffer full")); |
| 1651 /* TODO: fix 100% CPU after closing */ |
1650 /* TODO: fix 100% CPU after closing */ |
| 1652 close(source); |
1651 |
| |
1652 msim_close(session->gc); |
| 1653 return; |
1653 return; |
| 1654 } |
1654 } |
| 1655 |
1655 |
| 1656 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
1656 purple_debug_info("msim", "buffer at %d (max %d), reading up to %d\n", |
| 1657 session->rxoff, MSIM_READ_BUF_SIZE, |
1657 session->rxoff, MSIM_READ_BUF_SIZE, |
| 1670 { |
1670 { |
| 1671 purple_connection_error(gc, _("Read error")); |
1671 purple_connection_error(gc, _("Read error")); |
| 1672 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
1672 purple_debug_error("msim", "msim_input_cb: read error, ret=%d, " |
| 1673 "error=%s, source=%d, fd=%d (%X))\n", |
1673 "error=%s, source=%d, fd=%d (%X))\n", |
| 1674 n, strerror(errno), source, session->fd, session->fd); |
1674 n, strerror(errno), source, session->fd, session->fd); |
| 1675 close(source); |
1675 |
| |
1676 msim_close(session->gc); |
| 1676 return; |
1677 return; |
| 1677 } |
1678 } |
| 1678 else if (n == 0) |
1679 else if (n == 0) |
| 1679 { |
1680 { |
| 1680 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |
1681 purple_debug_info("msim", "msim_input_cb: server disconnected\n"); |