Skip to content

File descriptors lifetime bound to query not to message #27

Description

@andir

I am currently trying to iterate through all new mail with that matches tag:new and for each of those messages I am applying a set of processing rules to add/remove tags.

While doing that initially with a lot of email I did run into troubles since the program was running out of file descriptors.

It seems like the notmuch::Query struct dictates the lifetime of those. That isn't ideal if you want to iterate through a million mails.

The following code illustrates when it happens:

{
  let query = db.create_query("tag:new").unwrap();
  for message in query.search_messages().unwrap() {
      // so far no file descriptor has been created, it only is allocated once you try to access the headers (and potential other fields)

      let list_id = message.header("List-Id"); // this allocates a FD and fails once the FD limit has been reached

  } // FD should be free'ed here / after each iteration of the body / whenever `message` goes out of scope
}
// they are only free'ed when `query` runs out of scope

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions