porting finch to uClinux on blackfin

Bill Fassler bill.fassler at yahoo.com
Fri Oct 12 11:55:38 EDT 2007


I now have finch on my embedded development board and can create
an account, but fail during the DNS query.  I imagine this problem
might be uClinux and not necessarily finch, but I want to throw out
what I'm seeing just in case anyone has any suggestions.  It is
more challenging to debug in the embedded world.

To be more specific, my current problem seems to be in the area of
 spawning child processes.  The application now uses vfork( ) to create
a  child process for a DNS query.  This appears to go well and I obtain
 what looks like a valid PID, however when the code attempts to send
 the DNS request to the child it doesn't seem to exist. The errno
 seems to be "No Child Process".  Any idea why this might occur?
 
 This function appears to work OK:
 *******************************************************************
                                 Snippet # 1
*******************************************************************
 purple_dnsquery_resolver_new(gboolean show_debug)
 {
     PurpleDnsQueryResolverProcess *resolver;
     int child_out[2], child_in[2];
 
     /* Create pipes for communicating with the child process */
     if (pipe(child_out) || pipe(child_in)) {
         purple_debug_error("dns",
                    "Could not create pipes: %s\n", strerror(errno));
         return NULL;
     }
 
     resolver = g_new(PurpleDnsQueryResolverProcess, 1);
     resolver->inpa = 0;
 
     cope_with_gdb_brokenness();
 
     /* "Go fork and multiply." --Tommy Caldwell (Emily's dad, not the climber) */
     resolver->dns_pid = vfork();
 
     /* If we are the child process... */
     if (resolver->dns_pid == 0) {
         /* We should not access the parent's side of the pipes, so close them */
         close(child_out[0]);
         close(child_in[1]);
 
         purple_dnsquery_resolver_run(child_out[1], child_in[0], show_debug);
         /* The thread calls _exit() rather than returning, so we never get here */
     }
 
     /* We should not access the child's side of the pipes, so close them */
     close(child_out[1]);
     close(child_in[0]);
     if (resolver->dns_pid == -1) {
         purple_debug_error("dns",
                    "Could not create child process for DNS: %s\n",
                    strerror(errno));
         purple_dnsquery_resolver_destroy(resolver);
         return NULL;
     }
 
     resolver->fd_out = child_out[0];
     resolver->fd_in = child_in[1];
     number_of_dns_children++;
     purple_debug_info("dns",
                "Created new DNS child %d, there are now %d children.\n",
                resolver->dns_pid, number_of_dns_children);
 =========> We make it here so all seems well <==========
     return resolver;
 }
 ***************************************************************
                            End Snippet # 1
****************************************************************
 But I have a problem by the time I get here:
 
 ****************************************************************
                                 Snippet # 2 
****************************************************************
 send_dns_request_to_child(PurpleDnsQueryData *query_data,
         PurpleDnsQueryResolverProcess *resolver)
 {
     pid_t pid;
     dns_params_t dns_params;
     int rc;
     char ch;
 
     /* This waitpid might return the child's PID if it has recently
      * exited, or it might return an error if it exited "long
      * enough" ago that it has already been reaped; in either
      * instance, we can't use it. */
     pid = waitpid(resolver->dns_pid, NULL, WNOHANG);
     if (pid > 0) {
         purple_debug_warning("dns", "DNS child %d no longer exists\n",
                 resolver->dns_pid);
         purple_dnsquery_resolver_destroy(resolver);
         return FALSE;
     } else if (pid < 0) {
         purple_debug_warning("dns", "Wait for DNS child %d failed: %s\n",
                 resolver->dns_pid, strerror(errno));
         purple_dnsquery_resolver_destroy(resolver);
         return FALSE;
 ==========> I wind up here 8=( 
     }
 
     /* Copy the hostname and port into a single data structure */
     strncpy(dns_params.hostname, query_data->hostname, sizeof(dns_params.hostname) - 1);
     dns_params.hostname[sizeof(dns_params.hostname) - 1] = '\0';
     dns_params.port = query_data->port;
 
     /* Send the data structure to the child */
     rc = write(resolver->fd_in, &dns_params, sizeof(dns_params));
     if (rc < 0) {
         purple_debug_error("dns", "Unable to write to DNS child %d: %d\n",
                 resolver->dns_pid, strerror(errno));
         purple_dnsquery_resolver_destroy(resolver);
         return FALSE;
     }
 
     g_return_val_if_fail(rc == sizeof(dns_params), -1);
 
     /* Did you hear me? (This avoids some race conditions) */
     rc = read(resolver->fd_out, &ch, sizeof(ch));
     if (rc != 1 || ch != 'Y')
     {
         purple_debug_warning("dns",
                 "DNS child %d not responding. Killing it!\n",
                 resolver->dns_pid);
         purple_dnsquery_resolver_destroy(resolver);
         return FALSE;
     }
 
     purple_debug_info("dns",
             "Successfully sent DNS request to child %d\n",
             resolver->dns_pid);
 
     query_data->resolver = resolver;
 
     return TRUE;
 }
 ******************************************************************
                                    End snippet # 2
******************************************************************

Thanks as always,
Bill

Daniel Atallah <daniel.atallah at gmail.com> wrote: On 8/29/07, Bill Fassler  wrote:
> OK so I will start pouring over the log and see if I can tell what is
> missing.
>
> So I also need to port/cross-compile XML2??  I don't understand why Finch (a
> text-based IM) would need this!  I do understand that it is libpurple
> requiring it, but couldn't there be preprocessor directives to bypass
> compiling and linking stuff in libpurple that Finch doesn't really need?

libxml2 is a prerequisite for libpurple itself regardless of UI, so
Finch really needs it.

configure should have failed due to the missing dependency.

-D


       
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://pidgin.im/pipermail/devel/attachments/20071012/43e57152/attachment.html>


More information about the Devel mailing list