Software /
code /
prosody
Comparison
net/server_event.lua @ 4676:1ce2ff9ec313
net.server_event: Do not automatically close clients when closing a server port
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 24 Apr 2012 15:52:30 +0100 |
parent | 4468:938d878d8087 |
child | 4905:274ef78aa173 |
comparison
equal
deleted
inserted
replaced
4675:80f2d952d4c5 | 4676:1ce2ff9ec313 |
---|---|
341 self:_lock( true, true, false ) | 341 self:_lock( true, true, false ) |
342 debug "closing delayed until writebuffer is empty" | 342 debug "closing delayed until writebuffer is empty" |
343 return nil, "writebuffer not empty, waiting" | 343 return nil, "writebuffer not empty, waiting" |
344 end | 344 end |
345 else | 345 else |
346 debug( "try to close server with id:", self.id, "args:", now ) | 346 debug( "try to close server with id:", tostring(self.id), "args:", tostring(now) ) |
347 self.fatalerror = "server to close" | 347 self.fatalerror = "server to close" |
348 self:_lock( true ) | 348 self:_lock( true ) |
349 local count = 0 | 349 self:_close( 0 ) -- add new event to remove the server interface |
350 for _, item in ipairs( interfacelist( ) ) do | 350 return true |
351 if ( item.type ~= "server" ) and ( item._server == self ) then -- client/server match | |
352 if item:close( now ) then -- writebuffer was empty | |
353 count = count + 1 | |
354 end | |
355 end | |
356 end | |
357 local timeout = 0 -- dont wait for unfinished writebuffers of clients... | |
358 if not now then | |
359 timeout = cfg.WRITE_TIMEOUT -- ...or wait for it | |
360 end | |
361 self:_close( timeout ) -- add new event to remove the server interface | |
362 debug( "seconds remained until server is closed:", timeout ) | |
363 return count -- returns finished clients with empty writebuffer | |
364 end | 351 end |
365 end | 352 end |
366 | 353 |
367 function interface_mt:socket() | 354 function interface_mt:socket() |
368 return self.conn | 355 return self.conn |