-void
-tcpsconn::process_accept()
-{
- sockaddr_in sin;
- socklen_t slen = sizeof(sin);
- int s1 = accept(tcp_, (sockaddr *)&sin, &slen);
- if (s1 < 0) {
- perror("tcpsconn::accept_conn error");
- throw thread_exit_exception();
- }
-
- jsl_log(JSL_DBG_2, "accept_loop got connection fd=%d %s:%d\n",
- s1, inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
- connection *ch = new connection(mgr_, s1, lossy_);
-
- // garbage collect all dead connections with refcount of 1
- std::map<int, connection *>::iterator i;
- for (i = conns_.begin(); i != conns_.end();) {
- if (i->second->isdead() && i->second->ref() == 1) {
- jsl_log(JSL_DBG_2, "accept_loop garbage collected fd=%d\n",
- i->second->channo());
- i->second->decref();
- // Careful not to reuse i right after erase. (i++) will
- // be evaluated before the erase call because in C++,
- // there is a sequence point before a function call.
- // See http://en.wikipedia.org/wiki/Sequence_point.
- conns_.erase(i++);
- } else
- ++i;