Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

build error on Centos 5.8: IOV_MAX undeclared #84

Closed
jwaldmann opened this Issue · 13 comments

4 participants

jwaldmann Johan Tibell Kazu Yamamoto Ben Millwood
jwaldmann

when building version (2.4.0.1) on Centos 5.8 with ghc-7.6.1 I get

Bytestring.hsc:204:5: error: 'IOV_MAX' undeclared

building 2.3.1.1 works (that is the version that gets pulled in for bootstrapping cabal-install)

jwaldmann

defining __USE_XOPEN (as in commit 78342cc ) does not seem to work.

This reference https://bugzilla.redhat.com/show_bug.cgi?id=165427#c2 seems to suggest that one should define _XOPEN_SOURCE and indeed this works.

Johan Tibell
Owner

@kazu-yamamoto reported the same issue. If you guys can agree what the right fix is (e.g. what defined to use), I'm happy to merge a fix.

Kazu Yamamoto

@jwaldmann Would you look into what macro is necessary for your environment? Please read this thread:
#82

jwaldmann

I am no sure about "necessary". I can confirm that the following is sufficient for CentOS 5.8 (Kernel 2.6.18): jwaldmann@caddb7b

Actually, I don't know why the original code it is working with newer OS/kernel, as they don't seem to define IOV_MAX either, and on purpose: http://www.gnu.org/software/hurd/hurd/porting/guidelines.html

Johan Tibell
Owner

Have we come to a conclusion as to what to do? I can't really tell. IIRC we put in the IOV_MAX due to some error due to sending a too big value.

Kazu Yamamoto

I cannot understand this. But what about simply defining IOV_MAX (1024?) if not defined, instead of defining __USE_XOPEN or whatever.

Kazu Yamamoto

I send a pull request:
#85

jwaldmann

This feels like a hack.

Does the haskell/network code do any static allocation based on IOV_MAX?
http://cygwin.com/ml/cygwin/2002-12/msg00127.html

IOV_MAX should be replaced by some query at runtime? http://lists.debian.org/debian-hurd/2012/05/msg00120.html

Johan Tibell
Owner

Does the haskell/network code do any static allocation based on IOV_MAX?

We use IOV_MAX in Network.Socket.ByteString.sendMany to avoid passing more chunks to writev than the OS allows. We use to pass an arbitrary number of chunks in the past, which led to failures in some cases. Therefore we now cap the number of chunks we pass at a time to IOV_MAX.

I'm purposely trying to not do all the research myself this time, as I'm unfortunately quite snowed under, hoping that you guys could do it for me and come to a consensus as what to do. :)

jwaldmann

OK. the only place in the code that uses IOV_MAX seems to be: https://github.com/haskell/network/blob/master/Network/Socket/ByteString.hsc#L204

The "hack" probably is fine here: if a system does not define IOV_MAX, then it claims "there is no limit", so putting an arbitrary number (1024) should be ok.

Still, this is my amateur opinion. The haskell/network code seems mission-critical (I guess everyone gets it as a dependency of cabal-install), so any modification should be double-checked, by people who feel confident with writing low level, OS dependent code (I am not).

Johan Tibell
Owner

I went with #85.

Johan Tibell tibbe closed this
Kazu Yamamoto

Double-check is a good manner. Thank you for discussing.

Ben Millwood

I agree that the current solution is a hack. It seems like the Right Thing is to use sysconf, and unfortunately there's no good interface for that – the one in the unix package is woefully incomplete. We could of course import it ourselves.

I think what I would do is test definedness of IOV_MAX at the use site, not in the header file. That seems much less confusing for later developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.