winlin

close fd when delete connection object

@@ -35,6 +35,10 @@ SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd) @@ -35,6 +35,10 @@ SrsConnection::SrsConnection(SrsServer* srs_server, st_netfd_t client_stfd)
35 35
36 SrsConnection::~SrsConnection() 36 SrsConnection::~SrsConnection()
37 { 37 {
  38 + if (stfd) {
  39 + st_netfd_close(stfd);
  40 + stfd = NULL;
  41 + }
38 } 42 }
39 43
40 int SrsConnection::start() 44 int SrsConnection::start()
@@ -59,7 +63,7 @@ void SrsConnection::cycle() @@ -59,7 +63,7 @@ void SrsConnection::cycle()
59 63
60 // success. 64 // success.
61 if (ret == ERROR_SUCCESS) { 65 if (ret == ERROR_SUCCESS) {
62 - SrsInfo("client process normally finished. ret=%d", ret); 66 + SrsTrace("client process normally finished. ret=%d", ret);
63 } 67 }
64 68
65 // client close peer. 69 // client close peer.
@@ -148,6 +148,8 @@ void SrsServer::remove(SrsConnection* conn) @@ -148,6 +148,8 @@ void SrsServer::remove(SrsConnection* conn)
148 conns.erase(it); 148 conns.erase(it);
149 } 149 }
150 150
  151 + SrsInfo("conn removed. conns=%d", (int)conns.size());
  152 +
151 // all connections are created by server, 153 // all connections are created by server,
152 // so we delete it here. 154 // so we delete it here.
153 delete conn; 155 delete conn;
@@ -161,11 +163,13 @@ int SrsServer::accept_client(st_netfd_t client_stfd) @@ -161,11 +163,13 @@ int SrsServer::accept_client(st_netfd_t client_stfd)
161 163
162 // directly enqueue, the cycle thread will remove the client. 164 // directly enqueue, the cycle thread will remove the client.
163 conns.push_back(conn); 165 conns.push_back(conn);
  166 + SrsVerbose("add conn to vector. conns=%d", (int)conns.size());
164 167
165 // cycle will start process thread and when finished remove the client. 168 // cycle will start process thread and when finished remove the client.
166 if ((ret = conn->start()) != ERROR_SUCCESS) { 169 if ((ret = conn->start()) != ERROR_SUCCESS) {
167 return ret; 170 return ret;
168 } 171 }
  172 + SrsVerbose("conn start finished. ret=%d", ret);
169 173
170 return ret; 174 return ret;
171 } 175 }
@@ -182,13 +186,14 @@ void SrsServer::listen_cycle() @@ -182,13 +186,14 @@ void SrsServer::listen_cycle()
182 SrsWarn("ignore accept thread stoppped for accept client error"); 186 SrsWarn("ignore accept thread stoppped for accept client error");
183 continue; 187 continue;
184 } 188 }
  189 + SrsVerbose("get a client. fd=%d", st_netfd_fileno(client_stfd));
185 190
186 if ((ret = accept_client(client_stfd)) != ERROR_SUCCESS) { 191 if ((ret = accept_client(client_stfd)) != ERROR_SUCCESS) {
187 SrsWarn("accept client error. ret=%d", ret); 192 SrsWarn("accept client error. ret=%d", ret);
188 continue; 193 continue;
189 } 194 }
190 195
191 - SrsVerbose("accept client finished. ret=%d", ret); 196 + SrsVerbose("accept client finished. conns=%d, ret=%d", (int)conns.size(), ret);
192 } 197 }
193 } 198 }
194 199