aboutsummaryrefslogblamecommitdiffstats
path: root/commit.c
blob: a19aefed5e298c0f1938292c5f16f8bfde832bcb (plain) (tree)
1
2
3
4
5
6
7
8
9



                   



                        
                                                                                            
            
                     
 
                                                                        
                                                              
 


                                                            
 





                                                                        

              
#include <errno.h>
#include <string.h>
#include "commit.h"

void nfl_commit_init() {

}

void nfl_commit_worker(nflog_header_t* header, nflog_entry_t* store, const char* filename) {
    FILE* f;
    uint32_t written;

    debug("Comm worker #%u: commit to file %s\n", header->id, filename);
    ERR((f = fopen(filename, "wb")) == NULL, strerror(errno));

    // commit header
    written = fwrite(header, 1, sizeof(nflog_header_t), f);
    ERR(written != sizeof(nflog_header_t), strerror(errno));

    // commit store
    uint32_t store_size = sizeof(nflog_entry_t) * header->max_n_entries;
    written = fwrite(store, 1, store_size, f);
    ERR(written != store_size, strerror(errno));

    // Do fsync ?
    fclose(f);
}