[OpenAFS-devel] OpenAFS-1.2.10 on hp_ux11i

Srikanth Vishwanathan vsrikanth@in.ibm.com
Thu, 6 Nov 2003 09:43:19 +0530


This is a multipart message in MIME format.
--=_alternative 0017480665256DD6_=
Content-Type: text/plain; charset="US-ASCII"

> The code in the rx/HPUX.rx_knet.c is identical across all the releases. 
> 
> I am looking for ideas and mainly for the definition and documentation 
on 
> the kernel allocb, sosend and soreceive routines which are not defined 
> in any of the headers. 

We had a similar problem and we got help from HP - they informed us that
the crash was because our socket was not associated with a file structure.
Apparently, HPUX assumes that a socket is always associated with a file
which it tries to dereference somewhere in their code.

We added this to rxk_NewSocket for HP:

---- code snippet start ----

fp = falloc();
if (!fp) {
        goto error;
}

/* Get the file descriptor so we can free the file if there is an
 * error
 */
fd = (int) u.u_r.r_val1;

/* Initialize the file */
fp->f_flag = FREAD | FWRITE;
fp->f_type = DTYPE_SOCKET;
fp->f_ops  = &socketops;

/* And associate it with the socket */
fp->f_data = (void *) newSocket;
newSocket->so_fp = (void *) fp;

error:
    if (fd >= 0) {
        uffree(fd);
    }

    /* Free other resources */

---- code snippet end ----

We don't store the allocated file descriptor (which is required
to free the file), so we'll leak a file if we ever free the socket.
Fortunately, we don't ever free the socket in the client.

Srikanth.

--=_alternative 0017480665256DD6_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2><tt>&gt; The code in the rx/HPUX.rx_knet.c is identical
across all the releases. <br>
&gt; <br>
&gt; I am looking for ideas and mainly for the definition and documentation
on <br>
&gt; the kernel allocb, sosend and soreceive routines which are not defined
<br>
&gt; in any of the headers. </tt></font>
<br>
<br><font size=2><tt>We had a similar problem and we got help from HP -
they informed us that</tt></font>
<br><font size=2><tt>the crash was because our socket was not associated
with a file structure.</tt></font>
<br><font size=2><tt>Apparently, HPUX assumes that a socket is always associated
with a file</tt></font>
<br><font size=2><tt>which it tries to dereference somewhere in their code.</tt></font>
<br>
<br><font size=2><tt>We added this to rxk_NewSocket for HP:</tt></font>
<br>
<br><font size=2><tt>---- code snippet start ----</tt></font>
<br>
<br><font size=2><tt>fp = falloc();</tt></font>
<br><font size=2><tt>if (!fp) {</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; goto error;</tt></font>
<br><font size=2><tt>}</tt></font>
<br>
<br><font size=2><tt>/* Get the file descriptor so we can free the file
if there is an</tt></font>
<br><font size=2><tt>&nbsp;* error</tt></font>
<br><font size=2><tt>&nbsp;*/</tt></font>
<br><font size=2><tt>fd = (int) u.u_r.r_val1;</tt></font>
<br>
<br><font size=2><tt>/* Initialize the file */</tt></font>
<br><font size=2><tt>fp-&gt;f_flag = FREAD | FWRITE;</tt></font>
<br><font size=2><tt>fp-&gt;f_type = DTYPE_SOCKET;</tt></font>
<br><font size=2><tt>fp-&gt;f_ops &nbsp;= &amp;socketops;</tt></font>
<br>
<br><font size=2><tt>/* And associate it with the socket */</tt></font>
<br><font size=2><tt>fp-&gt;f_data = (void *) newSocket;</tt></font>
<br><font size=2><tt>newSocket-&gt;so_fp = (void *) fp;</tt></font>
<br>
<br><font size=2><tt>error:</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; if (fd &gt;= 0) {</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; &nbsp; &nbsp; uffree(fd);</tt></font>
<br><font size=2><tt>&nbsp; &nbsp; }</tt></font>
<br>
<br><font size=2><tt>&nbsp; &nbsp; /* Free other resources */</tt></font>
<br>
<br><font size=2><tt>---- code snippet end ----</tt></font>
<br>
<br><font size=2><tt>We don't store the allocated file descriptor (which
is required</tt></font>
<br><font size=2><tt>to free the file), so we'll leak a file if we ever
free the socket.</tt></font>
<br><font size=2><tt>Fortunately, we don't ever free the socket in the
client.</tt></font>
<br>
<br><font size=2><tt>Srikanth.</tt></font>
<br>
--=_alternative 0017480665256DD6_=--