void xdccd::IRCConnection::close() { std::lock_guard<std::mutex> lock(io_lock); std::lock_guard<std::mutex> time_lock(timeout_lock); message_received = false; timeout_triggered = false; timeout_timer.cancel(); reconnect_timer.cancel(); io_service.post([this]() { socket->close(); io_service.stop(); }); }
std::string types::get_date_string(const time_t t) { // use mutex since time functions are normally not thread-safe static boost::mutex time_mutex; static const char *TIME_FORMAT = "%a, %d %b %Y %H:%M:%S GMT"; static const unsigned int TIME_BUF_SIZE = 100; char time_buf[TIME_BUF_SIZE+1]; boost::mutex::scoped_lock time_lock(time_mutex); if (strftime(time_buf, TIME_BUF_SIZE, TIME_FORMAT, gmtime(&t)) == 0) time_buf[0] = '\0'; // failed; resulting buffer is indeterminate time_lock.unlock(); return std::string(time_buf); }