[comp.unix.questions] t_free before closing descriptor?

ade@clark.edu (Adrian Miranda) (07/25/90)

Pardon me if this is a dumb question, I'm trying to learn about
streams/TLI on System V r3.2.  In my function (actually it's not mine,
I'm porting smail3.1 to esix), I t_alloc a T_CALL structure.  I then
t_connect, pop the timod module and push the tirdwr module.  Finally,
the file descriptor is returned to the caller, which uses it to do
whatever.  What I'm wondering is, can I t_free the T_CALL structure at
the end of this function, even though the file descriptor will
continue to be used?  It appears that the structure is no longer
needed since smail will not be making any more TLI calls on the
descriptor.  But perhaps something is going on behind the scenes?

Adrian Miranda
uunet!clark!ade

sar0@cbnewsl.att.com (stephen.a.rago) (07/28/90)

In article <1990Jul25.045439.19914@clark.uucp>, ade@clark.edu (Adrian Miranda) writes:
> Pardon me if this is a dumb question, I'm trying to learn about
> streams/TLI on System V r3.2.  In my function (actually it's not mine,
> I'm porting smail3.1 to esix), I t_alloc a T_CALL structure.  I then
> t_connect, pop the timod module and push the tirdwr module.  Finally,
> the file descriptor is returned to the caller, which uses it to do
> whatever.  What I'm wondering is, can I t_free the T_CALL structure at
> the end of this function, even though the file descriptor will
> continue to be used?

Yes.

sar0@cbnewsl.att.com (stephen.a.rago) (07/28/90)

In article <1601@excelan.COM>, murthy@la.excelan.com (M.D. Srinivas Murthy) writes:
> In article <1990Jul25.045439.19914@clark.uucp> ade@clark.edu (Adrian Miranda) writes:
> >t_connect, pop the timod module and push the tirdwr module.  Finally,
> >the file descriptor is returned to the caller, which uses it to do
> >whatever.  What I'm wondering is, can I t_free the T_CALL structure at
> 
> Once you push the tirdwr module, you cannot use any TLI calls on that 
> descriptor. If you use, tirdwr module generates a fatal error, EPROTO.

Not strictly true.  t_free doesn't do anything except free the previously
allocated space.

> Is it necessary to pop the timod module before you push the tirdwr module?

Only if you want to avoid the overhead of an additional module on the stream.

Steve Rago
sar@attunix.att.com