Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1752650456, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"a27c376d8e60dc3fb3619ee6811a29b5", "commit": {"type":"commit", "time": 1647340089, "time_ofs": 0, "oid_tree": { "oid": "94092e73fbdae76d2e48e6ceea3899ffa286020b", "alias": []}, "oid":{ "oid": "2de67dd0aec413c40d3661d33d902c0de69abb48", "alias": []}, "msg": "file_ops: vfs: support prefix matches and use of bound ops members", "sig_commit": { "git_time": { "time": 1647340089, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1645079862, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "file_ops: vfs: support prefix matches and use of bound ops members\n\nVFS needs some small updates... pass in the bound fops as well as the\ncontext fops to the member callbacks. ZIP_FOPS only cared about doing\noperations on the platform / context vfs to walk the ZIP file, but other\nuses are valid where we are doing operation inside the bound VFS itself.\n\nAlso, stash a cx pointer into file ops struct for convenience.\n\n" , "diff": "diff --git a/include/libwebsockets/lws-vfs.h b/include/libwebsockets/lws-vfs.h\nindex 4b0c707..b59b4ac 100644\n--- a/include/libwebsockets/lws-vfs.h\n+++ b/include/libwebsockets/lws-vfs.h\n@@ -93,10 +93,15 @@ struct lws_fops_index {\n };\n \n struct lws_plat_file_ops {\n-\tlws_fop_fd_t (*LWS_FOP_OPEN)(const struct lws_plat_file_ops *fops,\n+\tlws_fop_fd_t (*LWS_FOP_OPEN)(const struct lws_plat_file_ops *fops_own,\n+\t\t\t\t const struct lws_plat_file_ops *fops,\n \t\t\t\t const char *filename, const char *vpath,\n \t\t\t\t lws_fop_flags_t *flags);\n \t/**\u003c Open file (always binary access if plat supports it)\n+\t * fops_own is the fops this was called through. fops is the base\n+\t * fops the open can use to find files to process as present as its own,\n+\t * like the zip fops does.\n+\t *\n \t * vpath may be NULL, or if the fops understands it, the point at which\n \t * the filename's virtual part starts.\n \t * *flags \u0026 LWS_FOP_FLAGS_MASK should be set to O_RDONLY or O_RDWR.\n@@ -121,7 +126,12 @@ struct lws_plat_file_ops {\n \t/**\u003c vfs path signatures implying use of this fops */\n \n \tconst struct lws_plat_file_ops *next;\n-\t/**\u003c NULL or next fops in list */\n+\t/**\u003c NULL or next fops in list... eg copy static fops def to heap\n+\t * and modify copy at runtime */\n+\n+\tstruct lws_context\t\t*cx;\n+\t/**\u003c the lws_context... eg copy static fops def to heap\n+\t * and modify copy at runtime */\n \n \t/* Add new things just above here ---^\n \t * This is part of the ABI, don't needlessly break compatibility */\n@@ -254,7 +264,8 @@ lws_vfs_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,\n */\n \n LWS_VISIBLE LWS_EXTERN lws_fop_fd_t\n-_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,\n+_lws_plat_file_open(const struct lws_plat_file_ops *fops_own,\n+\t\t const struct lws_plat_file_ops *fops, const char *filename,\n \t\t const char *vpath, lws_fop_flags_t *flags);\n LWS_VISIBLE LWS_EXTERN int\n _lws_plat_file_close(lws_fop_fd_t *fop_fd);\ndiff --git a/lib/core/context.c b/lib/core/context.c\nindex b927b44..c1fbf45 100644\n--- a/lib/core/context.c\n+++ b/lib/core/context.c\n@@ -892,6 +892,7 @@ lws_create_context(const struct lws_context_creation_info *info)\n \tcontext-\u003efops_platform.LWS_FOP_READ\t\u003d _lws_plat_file_read;\n \tcontext-\u003efops_platform.LWS_FOP_WRITE\t\u003d _lws_plat_file_write;\n \tcontext-\u003efops_platform.fi[0].sig\t\u003d NULL;\n+\tcontext-\u003efops_platform.cx\t\t\u003d context;\n \n \t/*\n \t * arrange a linear linked-list of fops starting from context-\u003efops\n@@ -908,6 +909,7 @@ lws_create_context(const struct lws_context_creation_info *info)\n \t/* make a soft copy so we can set .next */\n \tcontext-\u003efops_zip \u003d fops_zip;\n \tprev-\u003enext \u003d \u0026context-\u003efops_zip;\n+\tcontext-\u003efops_zip.cx \u003d context;\n \tprev \u003d (struct lws_plat_file_ops *)prev-\u003enext;\n #endif\n \ndiff --git a/lib/core/vfs.c b/lib/core/vfs.c\nindex e14d415..01c44d0 100644\n--- a/lib/core/vfs.c\n+++ b/lib/core/vfs.c\n@@ -88,20 +88,41 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path,\n \t * handled by a specific fops\n \t */\n \n+\tpf \u003d fops-\u003enext; /* the first one is always platform fops, so skip */\n+\twhile (pf) {\n+\t\tn \u003d 0;\n+\t\twhile (pf \u0026\u0026 n \u003c (int)LWS_ARRAY_SIZE(pf-\u003efi) \u0026\u0026 pf-\u003efi[n].sig) {\n+\t\t\tif (!strncmp(p, pf-\u003efi[n].sig, pf-\u003efi[n].len)) {\n+\t\t\t\t*vpath \u003d p + pf-\u003efi[n].len;\n+\t\t\t\t//lwsl_notice(\u0022%s: hit, vpath '%s'\u005cn\u0022,\n+\t\t\t\t//\t\t__func__, *vpath);\n+\t\t\t\treturn pf;\n+\t\t\t}\n+\t\t\tpf \u003d pf-\u003enext;\n+\t\t\tn++;\n+\t\t}\n+\t}\n+\n \twhile (p \u0026\u0026 *p) {\n \t\tif (*p !\u003d '/') {\n \t\t\tp++;\n \t\t\tcontinue;\n \t\t}\n-\t\t/* the first one is always platform fops, so skip */\n-\t\tpf \u003d fops-\u003enext;\n+\n+\t\tpf \u003d fops-\u003enext; /* the first one is always platform fops, so skip */\n \t\twhile (pf) {\n \t\t\tn \u003d 0;\n \t\t\twhile (n \u003c (int)LWS_ARRAY_SIZE(pf-\u003efi) \u0026\u0026 pf-\u003efi[n].sig) {\n+\t\t\t\tlwsl_warn(\u0022%s %s\u005cn\u0022, p, pf-\u003efi[n].sig);\n \t\t\t\tif (p \u003e\u003d vfs_path + pf-\u003efi[n].len)\n+\t\t\t\t\t/*\n+\t\t\t\t\t * Accept sigs like .... .zip or\n+\t\t\t\t\t * mysig...\n+\t\t\t\t\t */\n \t\t\t\t\tif (!strncmp(p - (pf-\u003efi[n].len - 1),\n \t\t\t\t\t\t pf-\u003efi[n].sig,\n-\t\t\t\t\t\t (unsigned int)(pf-\u003efi[n].len - 1))) {\n+\t\t\t\t\t\t (unsigned int)(pf-\u003efi[n].len - 1)) ||\n+\t\t\t\t\t !strncmp(p, pf-\u003efi[n].sig, pf-\u003efi[n].len)) {\n \t\t\t\t\t\t*vpath \u003d p + 1;\n \t\t\t\t\t\treturn pf;\n \t\t\t\t\t}\n@@ -125,7 +146,7 @@ lws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path,\n \n \tselected \u003d lws_vfs_select_fops(fops, vfs_path, \u0026vpath);\n \n-\treturn selected-\u003eLWS_FOP_OPEN(fops, vfs_path, vpath, flags);\n+\treturn selected-\u003eLWS_FOP_OPEN(selected, fops, vfs_path, vpath, flags);\n }\n \n \ndiff --git a/lib/plat/freertos/freertos-file.c b/lib/plat/freertos/freertos-file.c\nindex 033d258..f4ff76e 100644\n--- a/lib/plat/freertos/freertos-file.c\n+++ b/lib/plat/freertos/freertos-file.c\n@@ -31,7 +31,8 @@ int lws_plat_apply_FD_CLOEXEC(int n)\n \n \n lws_fop_fd_t IRAM_ATTR\n-_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,\n+_lws_plat_file_open(const struct lws_plat_file_ops *fops_own,\n+\t\t const struct lws_plat_file_ops *fops, const char *filename,\n \t\t const char *vpath, lws_fop_flags_t *flags)\n {\n \tstruct stat stat_buf;\ndiff --git a/lib/plat/unix/unix-file.c b/lib/plat/unix/unix-file.c\nindex 81cbb22..fe4960d 100644\n--- a/lib/plat/unix/unix-file.c\n+++ b/lib/plat/unix/unix-file.c\n@@ -79,7 +79,8 @@ lws_plat_read_file(const char *filename, void *buf, size_t len)\n }\n \n lws_fop_fd_t\n-_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,\n+_lws_plat_file_open(const struct lws_plat_file_ops *fops_own,\n+\t\t const struct lws_plat_file_ops *fops, const char *filename,\n \t\t const char *vpath, lws_fop_flags_t *flags)\n {\n \tstruct stat stat_buf;\ndiff --git a/lib/plat/windows/windows-file.c b/lib/plat/windows/windows-file.c\nindex ba78bc6..1cbdd0c 100644\n--- a/lib/plat/windows/windows-file.c\n+++ b/lib/plat/windows/windows-file.c\n@@ -33,7 +33,8 @@ int lws_plat_apply_FD_CLOEXEC(int n)\n }\n \n lws_fop_fd_t\n-_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,\n+_lws_plat_file_open(const struct lws_plat_file_ops *fops_own,\n+\t\t const struct lws_plat_file_ops *fops, const char *filename,\n \t\t const char *vpath, lws_fop_flags_t *flags)\n {\n \tHANDLE ret;\ndiff --git a/lib/roles/http/server/fops-zip.c b/lib/roles/http/server/fops-zip.c\nindex 832dcfc..43ed0c0 100644\n--- a/lib/roles/http/server/fops-zip.c\n+++ b/lib/roles/http/server/fops-zip.c\n@@ -315,7 +315,8 @@ lws_fops_zip_reset_inflate(lws_fops_zip_t priv)\n }\n \n static lws_fop_fd_t\n-lws_fops_zip_open(const struct lws_plat_file_ops *fops, const char *vfs_path,\n+lws_fops_zip_open(const struct lws_plat_file_ops *fops_own,\n+\t\t const struct lws_plat_file_ops *fops, const char *vfs_path,\n \t\t const char *vpath, lws_fop_flags_t *flags)\n {\n \tlws_fop_flags_t local_flags \u003d 0;\n@@ -342,7 +343,7 @@ lws_fops_zip_open(const struct lws_plat_file_ops *fops, const char *vfs_path,\n \n \t/* open the zip file itself using the incoming fops, not fops_zip */\n \n-\tpriv-\u003ezip_fop_fd \u003d fops-\u003eLWS_FOP_OPEN(fops, rp, NULL, \u0026local_flags);\n+\tpriv-\u003ezip_fop_fd \u003d fops-\u003eLWS_FOP_OPEN(fops_own, fops, rp, NULL, \u0026local_flags);\n \tif (!priv-\u003ezip_fop_fd) {\n \t\tlwsl_err(\u0022%s: unable to open zip %s\u005cn\u0022, __func__, rp);\n \t\tgoto bail1;\n@@ -652,4 +653,5 @@ struct lws_plat_file_ops fops_zip \u003d {\n \tNULL,\n \t{ { \u0022.zip/\u0022, 5 }, { \u0022.jar/\u0022, 5 }, { \u0022.war/\u0022, 5 } },\n \tNULL,\n+\tNULL,\n };\ndiff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c\nindex 667980d..b93fb86 100644\n--- a/lib/roles/http/server/server.c\n+++ b/lib/roles/http/server/server.c\n@@ -698,7 +698,7 @@ lws_http_serve(struct lws *wsi, char *uri, const char *origin,\n \t\tif (wsi-\u003ehttp.fop_fd)\n \t\t\tlws_vfs_file_close(\u0026wsi-\u003ehttp.fop_fd);\n \n-\t\twsi-\u003ehttp.fop_fd \u003d fops-\u003eLWS_FOP_OPEN(wsi-\u003ea.context-\u003efops,\n+\t\twsi-\u003ehttp.fop_fd \u003d fops-\u003eLWS_FOP_OPEN(fops, wsi-\u003ea.context-\u003efops,\n \t\t\t\t\t\t\tpath, vpath, \u0026fflags);\n \t\tif (!wsi-\u003ehttp.fop_fd) {\n \t\t\tlwsl_info(\u0022%s: Unable to open '%s': errno %d\u005cn\u0022,\n@@ -2755,7 +2755,7 @@ lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type,\n \tif (!wsi-\u003ehttp.fop_fd) {\n \t\tfops \u003d lws_vfs_select_fops(wsi-\u003ea.context-\u003efops, file, \u0026vpath);\n \t\tfflags |\u003d lws_vfs_prepare_flags(wsi);\n-\t\twsi-\u003ehttp.fop_fd \u003d fops-\u003eLWS_FOP_OPEN(wsi-\u003ea.context-\u003efops,\n+\t\twsi-\u003ehttp.fop_fd \u003d fops-\u003eLWS_FOP_OPEN(fops, wsi-\u003ea.context-\u003efops,\n \t\t\t\t\t\t\tfile, vpath, \u0026fflags);\n \t\tif (!wsi-\u003ehttp.fop_fd) {\n \t\t\tlwsl_info(\u0022%s: Unable to open: '%s': errno %d\u005cn\u0022,\ndiff --git a/minimal-examples-lowlevel/http-client/minimal-http-client-multi/minimal-http-client-multi.c b/minimal-examples-lowlevel/http-client/minimal-http-client-multi/minimal-http-client-multi.c\nindex b521b3d..bd43ba8 100644\n--- a/minimal-examples-lowlevel/http-client/minimal-http-client-multi/minimal-http-client-multi.c\n+++ b/minimal-examples-lowlevel/http-client/minimal-http-client-multi/minimal-http-client-multi.c\n@@ -562,7 +562,7 @@ int main(int argc, const char **argv)\n \t * It will just allocate for 1 internal and COUNT + 1 (allowing for h2\n \t * network wsi) that we will use.\n \t */\n-\tinfo.fd_limit_per_thread \u003d 1 + COUNT + 1;\n+\tinfo.fd_limit_per_thread \u003d 1 + COUNT + 8 + 1;\n \tinfo.register_notifier_list \u003d na;\n \tinfo.pcontext \u003d \u0026context;\n \n","s":{"c":1752650456,"u": 8316}} ],"g": 10731,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}