Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpServer.close doesn't block long enough #4155

Closed
nex3 opened this issue Jul 19, 2012 · 3 comments
Closed

HttpServer.close doesn't block long enough #4155

nex3 opened this issue Jul 19, 2012 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io

Comments

@nex3
Copy link
Member

nex3 commented Jul 19, 2012

The HttpServer.close method returns immediately, without waiting for the server to actually close. This means that if another server starts listening on the same port immediately after the first server is closed, it will fail. If some code runs before the second server starts listening, you have a race condition; if the interstitial code takes long enough, the second server will work, but if it executes quickly then you'll get a port conflict. This is what caused this build breakage: http://chromegw.corp.google.com/i/client.dart/builders/vm-mac-release/builds/4814/steps/tests/logs/stdio

Here's some example code:

    var server1 = new HttpServer();
    server1.listen('127.0.0.1', 3123);
    server1.close();
    // Code here causes a race condition
    var server2 = new HttpServer();
    server2.listen('127.0.0.1', 3123); // error: port 3123 already in use

An alternate solution would be to have HttpServer provide some asynchronous notification of when it was actually closed, such as #close returning a Future.

@sgjesse
Copy link
Contributor

sgjesse commented Apr 16, 2013

Added this to the M5 milestone.

@andersjohnsen
Copy link

With r25213 the Future returned from HttpServer.close (and ServerSocket.close) will complete once the port is closed and ready for re-use.


Removed this from the M5 milestone.
Added Fixed label.

@kevmoo
Copy link
Member

kevmoo commented May 14, 2014

Removed Area-IO label.
Added Area-Library, Library-IO labels.

@nex3 nex3 added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io labels May 14, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io
Projects
None yet
Development

No branches or pull requests

4 participants