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

Unix.establish_server can throw a "bad file descriptor" exception #3794

Closed
vicuna opened this issue Sep 20, 2005 · 1 comment
Closed

Unix.establish_server can throw a "bad file descriptor" exception #3794

vicuna opened this issue Sep 20, 2005 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 20, 2005

Original bug ID: 3794
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Eric Cooper
Version: 3.08.4
OS: Debian GNU/Linux
Submission from: c-24-3-154-200.hsd1.pa.comcast.net (24.3.154.200)

If the server function that is passed to Unix.establish_server closes the
in_channel before returning, the establish_server code will attempt to close the
out_channel, causing this exception. (Server code might want to do this to
indicate an error condition to its client, for example.)

Here is code that reproduces the problem:

open Unix

let main port =
  let proc input output =
    close_in input
  in
  establish_server proc (ADDR_INET (inet_addr_any, port))

let () = main 7777

It seems that the close_out in establish_server is unnecessary anyway, since it
is about to call exit, which closes all open descriptors. When I modified
establish_server to omit the close_out call, my application worked fine.

@vicuna
Copy link
Author

vicuna commented Sep 24, 2005

Comment author: administrator

Fixed as suggested in main branch, 2005-09-24, XL

@vicuna vicuna closed this as completed Sep 24, 2005
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant