Reply To: svn-1586 crashes after a scan

#10956
scot
Participant

On OpenBSD 4.1-current using mt-daapd-svn-1586 the first scan would work properly. Any additional scans, full, simple or automatic would cause the scanning thread to spin endlessly consuming an entire processor and doing a lot of nothing.

Running with “-d 7 -D scan” revealed that the recursion was not working, the scanner was spinning on the last track in the first directory it reached.

In my case […]/iTunes Music/Air/Virgin Suicides/13 Suicide Underground.mp3 would get processed endlessly.

I quickly found scan_path() in mp3-scanner.c and tossed in a mess of debugging code to see what was happening. When I changed the following lines it started to work. I’ve had 5 full scans on this code without the issue showing back up. I’m not sure which of the two changes fixed it, the NULL check should be exactly the same as what you had, but I’ve seen that kind of thing get eaten by gcc’s optimizer before.

I’ll re-launch with -d 9 and see if anything is getting logged.


err=readdir_r(current_dir,(struct dirent *)de,&pde);
if(err != 0) {
DPRINTF(E_DBG,L_SCAN,"Error on readdir_r: %sn",strerror(errno));
err=errno;
closedir(current_dir);
free(extensions);
errno=err;
return -1;
}

if (pde == NULL) break;

Edit: it throws a “Error on readdir_r: No such file or directory” at the end of each directory with -d 9, but it works.

In the following check, wouldn’t it be better to check for the . file first and .AppleDouble/Desktop second? If you are ignoring all . files, the cheaper test will speed things up…


if(S_ISDIR(sb.st_mode)) { /* follow dir */
if(conf_get_int("scanning","ignore_appledouble",1) &&
((strcasecmp(pde->d_name,".AppleDouble") == 0) ||
(strcasecmp(pde->d_name,".AppleDesktop") == 0))) {
DPRINTF(E_DBG,L_SCAN,"Skipping appledouble foldern");
} else if(conf_get_int("scanning","ignore_dotfiles",0) &&
pde->d_name[0] == '.') {
DPRINTF(E_DBG,L_SCAN,"Skipping dotfilen");
} else {
DPRINTF(E_WARN,L_SCAN,"Found %s.. recursingn",pde->d_name);
scan_path(mp3_path);
}

Logging would be less informative, but if you are ignore all . files… who cares if it’s .AppleDouble or not?