MCPcopy Create free account
hub / github.com/davisking/dlib / service_connection

Method service_connection

dlib/linker/linker_kernel_1.cpp:264–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262// ----------------------------------------------------------------------------------------
263
264 void linker::
265 service_connection (
266 void* param
267 )
268 {
269 linker& p = *static_cast<linker*>(param);
270
271 p.cons_mutex.lock();
272 // if the connections are gone for whatever reason then return
273 if (p.A == 0 || p.B == 0)
274 {
275 // signal that this function is ending
276 p.service_connection_running_mutex.lock();
277 p.service_connection_running = false;
278 p.service_connection_running_signaler.broadcast();
279 p.service_connection_running_mutex.unlock();
280 return;
281 }
282 connection& a = *p.A;
283 connection& b = *p.B;
284 p.cons_mutex.unlock();
285
286
287
288 // forward data from b to a
289 char buf[200];
290 long status;
291 bool error = false;
292 while (true)
293 {
294 status = b.read(buf,sizeof(buf));
295 // if there was an error reading from the socket
296 if (status == OTHER_ERROR)
297 {
298 error = true;
299 break;
300 }
301 else if (status == SHUTDOWN)
302 {
303 a.shutdown();
304 }
305
306
307 if (status <= 0)
308 {
309 // if b has closed normally
310 if (status == 0)
311 a.shutdown_outgoing();
312 break;
313 }
314
315
316 status = a.write(buf,status);
317 // if there was an error writing to the socket then break
318 if (status == OTHER_ERROR)
319 {
320 error = true;
321 break;

Callers

nothing calls this directly

Calls 7

shutdown_outgoingMethod · 0.80
lockMethod · 0.45
broadcastMethod · 0.45
unlockMethod · 0.45
readMethod · 0.45
shutdownMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected