Comparison

net/server_epoll.lua @ 9382:31a2be28729c

net.server_epoll: Protect from errors in get{peer,sock}name
author Kim Alvefur <zash@zash.se>
date Wed, 26 Sep 2018 13:52:10 +0200
parent 9381:80be543a3785
child 9383:3260902a5b22
comparison
equal deleted inserted replaced
9381:80be543a3785 9382:31a2be28729c
499 read_size = read_size or (server and server.read_size); 499 read_size = read_size or (server and server.read_size);
500 writebuffer = {}; 500 writebuffer = {};
501 tls_ctx = tls_ctx; 501 tls_ctx = tls_ctx;
502 }, interface_mt); 502 }, interface_mt);
503 503
504 if client.getpeername then 504 local ok, peername, peerport = pcall(client.getpeername, client);
505 conn.peername, conn.peerport = client:getpeername(); 505 if ok then
506 end 506 conn.peername, conn.peerport = peername, peerport;
507 if client.getsockname then 507 end
508 conn.sockname, conn.sockport = client:getsockname(); 508 local ok, sockname, sockport = pcall(client.getsockname, client);
509 if ok then
510 conn.sockname, conn.sockport = sockname, sockport;
509 end 511 end
510 return conn; 512 return conn;
511 end 513 end
512 514
513 -- A server interface has new incoming connections waiting 515 -- A server interface has new incoming connections waiting