Browse Source

share, transfer-manager: handle a case when all ports are busy

bboozzoo/share
Maciek Borzecki 7 years ago
parent
commit
74915af509
2 changed files with 6 additions and 1 deletions
  1. +4
    -0
      src/mconnect/share.vala
  2. +2
    -1
      src/mconnect/transfer-manager.vala

+ 4
- 0
src/mconnect/share.vala View File

@ -193,6 +193,10 @@ class ShareHandler : Object, PacketHandlerInterface {
uint16 port;
var listener = Core.instance().transfer_manager.make_listener(out port);
if (listener == null) {
warning("coult not allodate a listener");
return;
}
debug("allocated listener on port %u", port);
var t = new UploadTransfer(dev, listener, input, size);


+ 2
- 1
src/mconnect/transfer-manager.vala View File

@ -32,7 +32,7 @@ class TransferManager : Object {
new_transfer(job);
}
public SocketService make_listener(out uint16 listen_port) {
public SocketService? make_listener(out uint16 listen_port) {
var ss = new SocketService();
for (var port = PORT_MIN; port <= PORT_MAX; port++) {
var added = false;
@ -49,6 +49,7 @@ class TransferManager : Object {
return ss;
}
}
ss.close();
warning("could not find a free port to listen on");
return null;
}

Loading…
Cancel
Save