Changeset View
Changeset View
Standalone View
Standalone View
stand/efi/libefi/efihttp.c
Show First 20 Lines • Show All 569 Lines • ▼ Show 20 Lines | efihttp_fs_open(const char *path, struct open_file *f) | ||||
if (!efihttp_init_done) | if (!efihttp_init_done) | ||||
return (ENXIO); | return (ENXIO); | ||||
/* | /* | ||||
* If any path fails to open, try with a trailing slash in | * If any path fails to open, try with a trailing slash in | ||||
* case it's a directory. | * case it's a directory. | ||||
*/ | */ | ||||
err = _efihttp_fs_open(path, f); | err = _efihttp_fs_open(path, f); | ||||
if (err != 0) { | if (err != 0) { | ||||
/* | |||||
scottph: It seems like this workaround should be moved a few lines up, before calling _efihttp_fs_open()… | |||||
Done Inline ActionsNo, that would be wrong. In normal operation, efihttp_fs_open is only called once before other code ends up calling efihttp_dev_close. Then for the next file, efihttp_dev_open gets called, followed eventually by efihttp_fs_open. So the only time we need to explicitly close and open the dev is when we want to call _efihttp_fs_open twice in a row ourselves. bcran: No, that would be wrong. In normal operation, `efihttp_fs_open` is only called once before… | |||||
* Work around a bug in the EFI HTTP implementation which | |||||
* causes a crash if the http instance isn't torn down | |||||
* between requests. | |||||
* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | |||||
*/ | |||||
efihttp_dev_close(f); | |||||
efihttp_dev_open(f); | |||||
path_slash = malloc(strlen(path) + 2); | path_slash = malloc(strlen(path) + 2); | ||||
if (path_slash == NULL) | if (path_slash == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
strcpy(path_slash, path); | strcpy(path_slash, path); | ||||
strcat(path_slash, "/"); | strcat(path_slash, "/"); | ||||
err = _efihttp_fs_open(path_slash, f); | err = _efihttp_fs_open(path_slash, f); | ||||
free(path_slash); | free(path_slash); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | while (res > 0) { | ||||
res -= min(1500, res) - res2; | res -= min(1500, res) - res2; | ||||
} | } | ||||
free(buf); | free(buf); | ||||
return (0); | return (0); | ||||
} else if (where == SEEK_SET) { | } else if (where == SEEK_SET) { | ||||
path = fh->path; | path = fh->path; | ||||
fh->path = NULL; | fh->path = NULL; | ||||
efihttp_fs_close(f); | efihttp_fs_close(f); | ||||
/* | |||||
* Work around a bug in the EFI HTTP implementation which | |||||
* causes a crash if the http instance isn't torn down | |||||
* between requests. | |||||
* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917 | |||||
*/ | |||||
efihttp_dev_close(f); | |||||
efihttp_dev_open(f); | |||||
err = efihttp_fs_open(path, f); | err = efihttp_fs_open(path, f); | ||||
free(path); | free(path); | ||||
if (err != 0) | if (err != 0) | ||||
return (err); | return (err); | ||||
return efihttp_fs_seek(f, offset, where); | return efihttp_fs_seek(f, offset, where); | ||||
} | } | ||||
return (EIO); | return (EIO); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 55 Lines • Show Last 20 Lines |
It seems like this workaround should be moved a few lines up, before calling _efihttp_fs_open() instead of after receiving a !=0 return value from it.