<commit_before>/*
 * Glue for libnfs.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "Client.hxx"
#include "Error.hxx"
#include "Handler.hxx"
#include "pool.hxx"
#include "system/Error.hxx"
#include "system/fd_util.h"
#include "event/SocketEvent.hxx"
#include "event/TimerEvent.hxx"
#include "util/Cancellable.hxx"

extern "C" {
#include <nfsc/libnfs.h>
}

#include <boost/intrusive/list.hpp>
#include <boost/intrusive/set.hpp>

#include <iterator>

#include <string.h>
#include <fcntl.h>
#include <sys/poll.h>
#include <sys/stat.h>

class NfsFile;

/**
 * A handle that is passed to the caller.  Each file can have multiple
 * public "handles", one for each caller.  That way, only one #nfsfh
 * (inside #NfsFile) is needed.
 */
class NfsFileHandle final
    : public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>,
      Cancellable {

    NfsFile &file;

    /**
     * A child of #NfsFile::pool.
     */
    struct pool &pool;

    /**
     * The pool provided by the caller.  It must be referenced until
     * the response has been delivered.
     */
    struct pool &caller_pool;

    enum {
        /**
         * Waiting for the file to be opened.  The
         * nfs_client_open_file_handler will be invoked next.
         */
        WAITING,

        /**
         * The file is ready, the nfs_client_open_file_handler has
         * been invoked already.
         */
        IDLE,

        /**
         * A request by this handle is pending inside libnfs.  This
         * object can only be freed when all libnfs operations
         * referencing this object are finished.
         */
        PENDING,

        /**
         * istream_close() has been called by the istream handler
         * while the state was #PENDING.  This object cannot be
         * destroyed until libnfs has released the reference to this
         * object (queued async call with private_data pointing to
         * this object).  As soon as libnfs calls back, the object<commit_msg>nfs/Client: update API documentation<commit_after>/*
 * Glue for libnfs.
 *
 * author: <NAME> <<EMAIL>>
 */

#include "Client.hxx"
#include "Error.hxx"
#include "Handler.hxx"
#include "pool.hxx"
#include "system/Error.hxx"
#include "system/fd_util.h"
#include "event/SocketEvent.hxx"
#include "event/TimerEvent.hxx"
#include "util/Cancellable.hxx"

extern "C" {
#include <nfsc/libnfs.h>
}

#include <boost/intrusive/list.hpp>
#include <boost/intrusive/set.hpp>

#include <iterator>

#include <string.h>
#include <fcntl.h>
#include <sys/poll.h>
#include <sys/stat.h>

class NfsFile;

/**
 * A handle that is passed to the caller.  Each file can have multiple
 * public "handles", one for each caller.  That way, only one #nfsfh
 * (inside #NfsFile) is needed.
 */
class NfsFileHandle final
    : public boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>,
      Cancellable {

    NfsFile &file;

    /**
     * A child of #NfsFile::pool.
     */
    struct pool &pool;

    /**
     * The pool provided by the caller.  It must be referenced until
     * the response has been delivered.
     */
    struct pool &caller_pool;

    enum {
        /**
         * Waiting for the file to be opened.  The
         * #NfsClientOpenFileHandler will be invoked next.
         */
        WAITING,

        /**
         * The file is ready, the #NfsClientOpenFileHandler has been
         * invoked already.
         */
        IDLE,

        /**
         * A request by this handle is pending inside libnfs.  This
         * object can only be freed when all libnfs operations
         * referencing this object are finished.
         */
        PENDING,

        /**
         * istream_close() has been called by the istream handler
         * while the state was #PENDING.  This object cannot be
         * destroyed until libnfs has released the reference to this
         * object (queued async call with private_data pointing to
         * this object).  As soon as libnfs calls back, the object
{'fraction_non_alphanumeric': 0.10625154435384235, 'fraction_numerical': 0.0, 'mean_word_length': 2.4926660914581538, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5067302', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1271, 'n_words': 408}