Commit 381b734c authored by old-bear's avatar old-bear

+ Fix a bug that socket options must be set before adding to epoll

parent a0f635ec
...@@ -648,6 +648,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { ...@@ -648,6 +648,7 @@ int Socket::Create(const SocketOptions& options, SocketId* id) {
} }
m->_last_writetime_us.store(cpuwide_now, butil::memory_order_relaxed); m->_last_writetime_us.store(cpuwide_now, butil::memory_order_relaxed);
m->_unwritten_bytes.store(0, butil::memory_order_relaxed); m->_unwritten_bytes.store(0, butil::memory_order_relaxed);
m->_options = options;
CHECK(NULL == m->_write_head.load(butil::memory_order_relaxed)); CHECK(NULL == m->_write_head.load(butil::memory_order_relaxed));
// Must be last one! Internal fields of this Socket may be access // Must be last one! Internal fields of this Socket may be access
// just after calling ResetFileDescriptor. // just after calling ResetFileDescriptor.
...@@ -659,10 +660,6 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { ...@@ -659,10 +660,6 @@ int Socket::Create(const SocketOptions& options, SocketId* id) {
return -1; return -1;
} }
*id = m->_this_id; *id = m->_this_id;
m->_options = options;
if (m->_ssl_state == SSL_UNKNOWN) {
CHECK(m->_options.ssl_ctx);
}
return 0; return 0;
} }
...@@ -1774,9 +1771,6 @@ int Socket::SSLHandshake(int fd, bool server_mode) { ...@@ -1774,9 +1771,6 @@ int Socket::SSLHandshake(int fd, bool server_mode) {
if (_options.ssl_ctx == NULL) { if (_options.ssl_ctx == NULL) {
if (server_mode) { if (server_mode) {
LOG(ERROR) << "Lack SSL configuration to handle SSL request"; LOG(ERROR) << "Lack SSL configuration to handle SSL request";
std::stringstream ss;
DebugSocket(ss, id());
LOG(ERROR) << ss;
return -1; return -1;
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment