Matthew Lye wrote:
> 
> On 10-Sep-07, at 10:06 PM, Christian Biere wrote:
> >> As best I can figure, the problem was caused by a hackneyed attempt
> >> to use dmesh_fill_alternate() with, um, an uninitialized gnet_host_t
> >> pointer as the 'vector', which as far as I can tell means 'pointer to
> >> the array that gets filled in'.
> >
> > I can't quite follow you. Where do you see dmesh_fill_alternate()  
> > in this
> > code path?
> 
> Apologies.  A context error, I had relied on a clause of the previous  
> message for disambiguation.
> I was referring to my own code appending sha1 (properly) and source  
> (very improperly) information to the completed files via xattr.
> 
> 
> >> I would have identified this as a
> >> mistake if I had caught it, but I didn't.
> >
> > Which code exactly looks dubious to you?
> 
> Dubious code circa 10760 in "downloads.c", commented out:
> >             /* Send a notification */
> >             dbus_util_send_message(DBS_EVT_DOWNLOAD_DONE, 
> > download_pathname(d));
> >             
> >             
> >             /*      Append attributes to file?                              
> >         */
> >             
> >             setxattr(fi->pathname,"SHA1Value", sha1_base32(d->sha1), 
> > 64,0,XATTR_CREATE);
> >             
> > //          gnet_host_t *hostlist;  <--- WRONG!
> > //          gint thecount = dmesh_count(d->sha1);
> > //          dmesh_fill_alternate(d->sha1,hostlist,thecount);

Right, that's wrong. You better do something like this:

                gnet_host_t hvec[256];
                int hcnt, i;
                hcnt = dmesh_fill_alternate(d->sha1, hvec, G_N_ELEMENTS(hvec));
                for (i = 0; i < hcnt; i++) {
                        char name[16];
                        const char *value;

                        gm_snprintf(name, sizeof name, "AltLoc%u", i);
                        value = 
host_addr_port_to_string(gnet_host_addr(&hvec[i]), gnet_host_port(&hvec[i]));
                        setxattr(fi->pathname, name, value, strlen(value), 0, 
XATTR_CREATE);
                }


-- 
Christian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
gtk-gnutella-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to