Re: Some patchs

2008-06-27 Thread Denys Vlasenko
On Thursday 26 June 2008 16:17, Pascal Bellard wrote:
 Hello,
 
 Udhcpc: do not hang when network is down
 http://hg.slitaz.org/wok/raw-file/be0892d9efd5/busybox/stuff/busybox-1.11.0-dhcpc.u

Actually, I want to hang (actually, retry forever) when network is down.
I run udhcpc indefinitely, and I don't want it to bail out just because
e.g. some other async script failed to up the interface in time.

You obvious want it ot exit. This already works!

Look at the code again:

if (packet_num  discover_retries) {
if (packet_num == 0)
xid = random_xid();

send_discover(xid, requested_ip); /* 
broadcast */

timeout = discover_timeout;
packet_num++;
continue;
}

we are here if packet_num = discover_retries. now...

udhcp_run_script(NULL, leasefail);
if (opt  OPT_b) { /* background if no lease */
bb_info_msg(No lease, forking to 
background);
client_background();
/* do not background again! */
opt = ((opt  ~OPT_b) | OPT_f);
} else
if (opt  OPT_n) { /* abort if no lease */
bb_info_msg(No lease, failing);
retval = 1;
goto ret;
}

Yes! this is it! if you want udhcpc to exit, give it -n option.

/* wait before trying again */
timeout = tryagain_timeout;
packet_num = 0;
continue;

Am I missing something?
--
vda
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: Some patchs

2008-06-27 Thread Denys Vlasenko
On Thursday 26 June 2008 16:17, Pascal Bellard wrote:
 unlzma: memory leak
 http://hg.slitaz.org/wok/raw-file/be0892d9efd5/busybox/stuff/busybox-1.11.0-unlzma.u

Good catch.

@@ -491,10 +491,14 @@

if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
  bad:
-   rc_free(rc);
-   return -1;
+   len = -1;
+   }
+   else {
+   USE_DESKTOP(total_written += buffer_pos;)
+   len = USE_DESKTOP(total_written) + 0;

The only problem here is that len is int, whereas total_written is llong.

}
rc_free(rc);
-   USE_DESKTOP(total_written += buffer_pos;)
-   return USE_DESKTOP(total_written) + 0;
+   rc_free(buffer);
+   rc_free(p);
+   return len;
 }

Oh, and we also leak buffer! :(

I propose the following:

{
USE_DESKTOP(total_written += buffer_pos;)
SKIP_DESKTOP(int total_written = 0; /* success */)
if (full_write(dst_fd, buffer, buffer_pos) != 
(ssize_t)buffer_pos) {
 bad:
total_written = -1; /* failure */
}
rc_free(rc);
free(p);
free(buffer);
return total_written;
}
}

--
vda

___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox


Re: Some patchs

2008-06-27 Thread Denys Vlasenko
On Thursday 26 June 2008 16:17, Pascal Bellard wrote:
 New feature: stat -m displays file map
 http://hg.slitaz.org/wok/raw-file/be0892d9efd5/busybox/stuff/busybox-1.11.0-stat.u

Does this mimic GNU stat?
--
vda
___
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox