This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Using the fd's underlying guile fports


| The library I'm writing glue code for has a trace feature which results in
| a low-level trace being written to a specified (FILE *) passed in. To make
| this flexible I would like to be able to accept any fport as an argument
| to the trace function. That way trace could be done to any stream very
| easily, without my having to write code to do fopen popen etc.
| 
| However there is a potential problem with the port being written to or
| read from by guile whilst it's underlying fd is written to from the
| third-party library.
| 
| It seems that this will be a common situation. Does anyone see any merit
| in having some sort of locking mechanism in the ports interface to prevent
| scheme-level access to ports whose underlying file descriptors are in use?
| This could be just a count, bumped each time the underlying fd is
| obtained, and decremented each time it is released. Any attempt to read or
| write or seek on the port should result in an error of some kind. Is this
| by any chance what the revealed count is? 

Could you use a mutex? 

The revealed count indicates whether the port owns its descriptor.
If the count is greater than 0 then the descriptor shouldn't be
closed when the port is gc'd (currently implemented by not gc'ing the
port, but that's not required now.)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]