ERROR: open() failed: 2 using new PublishQueueExt library

During the scale-up of our new firmware tests that includes the new PublishQueueExt library, we've seen these errors being thrown:

0000240159 [wiring] ERROR: open() failed: 2

0000240159 [app.pubq] ERROR: error saving event to fileNum 5

0000240169 [wiring] ERROR: open() failed: 2

0000240169 [app.pubq] ERROR: error saving event to fileNum 6

0000240183 [wiring] ERROR: open() failed: 2

0000240183 [app.pubq] ERROR: error saving event to fileNum 7

Which is thrown from the

event.saveData(queueFilePath.c_str()) == SYSTEM_ERROR_NONE; call

Which in turn fails here:

int CloudEvent::saveData(const char* path) {
    if (!isReadable()) {
        return error();
    }
    int fd = open(path, O_CREAT | O_TRUNC | O_WRONLY, S_IRWXU);
    if (fd < 0) {
        LOG(ERROR, "open() failed: %d", errno);
        return Error::FILE;
    }

A small note is that I use a custom dir for the events, but it works on other devices for some reason:

   // Initialize POSIX-based queue system
   PublishQueueExt::instance().setup();
   PublishQueueExt::instance().withDirPath(DeviceConfigurationConstants::PUBLISH_QUEUE_DIRECTORY);

If your custom directory is more than one level deep the parent directory must also exist. It uses mkdir which does not recursively create directories and will fail creating the inner directory if the parent doesn't exist.

However I think the problem is that withDirPath needs to go before PublishQueueExt::instance().setup, because during the setup call, it creates and scans the directory. If you change it later, it won't create the directory.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.