fix build
[m6w6/ext-psi] / src / context.c
index 4dcd92092f6cecd65ac69e872741cdc7f3a7eb92..f480ebdce05c7d9fd888a42ccb36a8acdd899ce7 100644 (file)
@@ -23,7 +23,9 @@
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/
 
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 #include "php.h"
 
@@ -61,8 +63,7 @@
 #include "token.h"
 #include "parser.h"
 
-#include "php_psi_posix.h"
-
+PHP_MINIT_FUNCTION(psi_context);
 PHP_MINIT_FUNCTION(psi_context)
 {
        unsigned flags = 0;
@@ -100,6 +101,7 @@ PHP_MINIT_FUNCTION(psi_context)
        return SUCCESS;
 }
 
+PHP_MSHUTDOWN_FUNCTION(psi_context);
 PHP_MSHUTDOWN_FUNCTION(psi_context)
 {
        if (psi_check_env("PSI_DUMP")) {
@@ -304,11 +306,17 @@ void psi_context_build(struct psi_context *C, const char *paths)
                n = php_scandir(ptr, &entries, psi_select_dirent, alphasort);
 
                if (n < 0) {
+                       char cwd[PATH_MAX];
                        C->error(PSI_DATA(C), NULL, PSI_WARNING,
-                                       "Failed to scan PSI directory '%s':%s", strerror(errno));
+                                       "Failed to scan PSI directory '%s%s%s': %s",
+                                       *ptr == '/' ? "" : getcwd(cwd, PATH_MAX),
+                                       *ptr != '/' && *ptr != '.' ? "/" : "",
+                                       ptr, strerror(errno));
                } else {
                        for (i = 0; i < n; ++i) {
                                worker = psi_context_build_worker_init(C, ptr, entries[i]->d_name);
+                               PSI_DEBUG_PRINT(C, "PSI: init worker(%p) for %s/%s\n",
+                                               worker, ptr, entries[i]->d_name);
                                if (worker) {
                                        workers = psi_plist_add(workers, &worker);
                                }
@@ -333,6 +341,7 @@ void psi_context_build(struct psi_context *C, const char *paths)
 
                while (psi_plist_count(workers) && active < pool) {
                        if (psi_plist_pop(workers, &worker)) {
+                               PSI_DEBUG_PRINT(C, "PSI: starting worker %p\n", worker);
                                if (psi_context_build_worker_exec(worker)) {
                                        running = psi_plist_add(running, &worker);
                                        ++active;
@@ -344,13 +353,17 @@ void psi_context_build(struct psi_context *C, const char *paths)
 
                        while (psi_plist_get(running, i++, &worker)) {
                                if (psi_context_build_worker_done(worker)) {
+                                       PSI_DEBUG_PRINT(C, "PSI: collecting worker %p\n", worker);
                                        psi_context_add(C, &worker->parser);
 
                                        psi_plist_del(running, --i, NULL);
                                        psi_context_build_worker_free(&worker);
 
                                        if (psi_plist_pop(workers, &worker)) {
-                                               psi_plist_add(running, &worker);
+                                               PSI_DEBUG_PRINT(C, "PSI: starting worker %p\n", worker);
+                                               if (psi_context_build_worker_exec(worker)) {
+                                                       running = psi_plist_add(running, &worker);
+                                               }
                                        } else {
                                                --active;
                                        }