Skip to content

fdSocket should not be deprecated #418

Description

@bitc

The docs for fdSocket explain why it can be dangerous, and the docs recommend using withFdSocket instead.

This is a great suggestion, but sometimes the structure of your code does not allow you to use a "with" style. (In my program, I need to pass the socket fd to some C code that will continue to write to it after my Haskell code block returns)

It is my understanding that it is possible to use fdSocket safely: you simply must make sure not to close the Socket while you are still using the fd. (And to make sure that you hang on to the Socket somewhere so that the GC doesn't get it -- but you should be holding on to it anyway so that you can close it when you are finished with it)

So I request that the fdSocket function not be deprecated. I agree that the should have a warning, but the function should continue to be available and supported in future versions of this package.

Thank you

Activity

  1. kazu-yamamoto commented on Aug 4, 2019

    @kazu-yamamoto
    Collaborator

    Relating to #398

  2. kazu-yamamoto commented on Aug 4, 2019

    @kazu-yamamoto
    Collaborator
  3. kazu-yamamoto commented on Aug 4, 2019

    @kazu-yamamoto
    Collaborator

    @bitc I think your observation makes sense. I have no strong opinion. Please discuss this issue with guys above.

  4. takano-akio commented on Aug 4, 2019

    @takano-akio
    Contributor

    Sounds reasonable to me.

    Should we follow the same pattern as ForeinPtr here? It provides the functions unsafeForeignPtrToPtr and touchForeignPtr for this use case. We could similarly provide unsafeFdSocket and touchSocket.

  5. kazu-yamamoto commented on Aug 5, 2019

    @kazu-yamamoto
    Collaborator

    @takano-akio If you provide a PR, it would be highly appreciated.

  6. kazu-yamamoto commented on Aug 28, 2019

    @kazu-yamamoto
    Collaborator
  7. fumieval commented on Aug 29, 2019

    @fumieval
    Contributor

    It's a fairly simple change. I can do it if you don't have time

  8. kazu-yamamoto commented on Aug 29, 2019

    @kazu-yamamoto
    Collaborator

    @fumieval Welcome!

  9. takano-akio commented on Aug 29, 2019

    @takano-akio
    Contributor

    I'll do this today.

  10. added a commit that references this issue on Aug 29, 2019
    746e608
  11. added a commit that references this issue on Sep 2, 2019
    d0557cf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions