mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 23:43:30 +00:00
Improving the patch for mairix for mbox>2GB.
https://github.com/rc0/mairix/pull/19
This commit is contained in:
parent
df2b9b48cb
commit
4eb1e346c6
@ -10,9 +10,10 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
buildInputs = [ zlib bzip2 bison flex ];
|
buildInputs = [ zlib bzip2 bison flex ];
|
||||||
|
|
||||||
# https://github.com/rc0/mairix/issues/12
|
# https://github.com/rc0/mairix/pull/19
|
||||||
patches = [ ./mmap.patch ];
|
patches = [ ./mmap.patch ];
|
||||||
patchFlags = "-p2";
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
homepage = http://www.rc0.org.uk/mairix;
|
homepage = http://www.rc0.org.uk/mairix;
|
||||||
|
@ -1,25 +1,29 @@
|
|||||||
Fix "Cannot allocate memory" on mmap of files bigger than 2GiB.
|
Making mairix work with mbox files over 2GB.
|
||||||
|
|
||||||
https://github.com/rc0/mairix/issues/12
|
https://github.com/rc0/mairix/pull/19
|
||||||
|
|
||||||
diff -ruN t/mairix-0.22/mairix.h mairix/mairix-0.22/mairix.h
|
diff --git a/mairix.h b/mairix.h
|
||||||
--- t/mairix-0.22/mairix.h 2010-06-05 14:41:10.000000000 -0700
|
index 2480492..cb25824 100644
|
||||||
+++ mairix/mairix-0.22/mairix.h 2015-07-08 13:33:06.678718524 -0700
|
--- a/mairix.h
|
||||||
@@ -327,8 +327,8 @@
|
+++ b/mairix.h
|
||||||
|
@@ -327,9 +327,9 @@ enum data_to_rfc822_error {
|
||||||
|
DTR8_BAD_HEADERS, /* corrupt headers */
|
||||||
DTR8_BAD_ATTACHMENT /* corrupt attachment (e.g. no body part) */
|
DTR8_BAD_ATTACHMENT /* corrupt attachment (e.g. no body part) */
|
||||||
};
|
};
|
||||||
struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, int length, enum data_to_rfc822_error *error);
|
-struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, int length, enum data_to_rfc822_error *error);
|
||||||
-void create_ro_mapping(const char *filename, unsigned char **data, int *len);
|
-void create_ro_mapping(const char *filename, unsigned char **data, int *len);
|
||||||
-void free_ro_mapping(unsigned char *data, int len);
|
-void free_ro_mapping(unsigned char *data, int len);
|
||||||
|
+struct rfc822 *data_to_rfc822(struct msg_src *src, char *data, size_t length, enum data_to_rfc822_error *error);
|
||||||
+void create_ro_mapping(const char *filename, unsigned char **data, size_t *len);
|
+void create_ro_mapping(const char *filename, unsigned char **data, size_t *len);
|
||||||
+void free_ro_mapping(unsigned char *data, size_t len);
|
+void free_ro_mapping(unsigned char *data, size_t len);
|
||||||
char *format_msg_src(struct msg_src *src);
|
char *format_msg_src(struct msg_src *src);
|
||||||
|
|
||||||
/* In tok.c */
|
/* In tok.c */
|
||||||
diff -ruN t/mairix-0.22/mbox.c mairix/mairix-0.22/mbox.c
|
diff --git a/mbox.c b/mbox.c
|
||||||
--- t/mairix-0.22/mbox.c 2010-06-05 14:41:10.000000000 -0700
|
index ebbfa78..396e27d 100644
|
||||||
+++ mairix/mairix-0.22/mbox.c 2015-07-08 13:32:45.126280861 -0700
|
--- a/mbox.c
|
||||||
@@ -816,7 +816,7 @@
|
+++ b/mbox.c
|
||||||
|
@@ -816,7 +816,7 @@ void build_mbox_lists(struct database *db, const char *folder_base, /*{{{*/
|
||||||
mb->n_old_msgs_valid = mb->n_msgs;
|
mb->n_old_msgs_valid = mb->n_msgs;
|
||||||
} else {
|
} else {
|
||||||
unsigned char *va;
|
unsigned char *va;
|
||||||
@ -28,28 +32,65 @@ diff -ruN t/mairix-0.22/mbox.c mairix/mairix-0.22/mbox.c
|
|||||||
create_ro_mapping(mb->path, &va, &len);
|
create_ro_mapping(mb->path, &va, &len);
|
||||||
if (va) {
|
if (va) {
|
||||||
rescan_mbox(mb, (char *) va, len);
|
rescan_mbox(mb, (char *) va, len);
|
||||||
@@ -852,7 +852,7 @@
|
@@ -852,7 +852,7 @@ int add_mbox_messages(struct database *db)/*{{{*/
|
||||||
int any_new = 0;
|
int any_new = 0;
|
||||||
int N;
|
int N;
|
||||||
unsigned char *va;
|
unsigned char *va;
|
||||||
- int valen;
|
- int valen;
|
||||||
+ size_t valen;
|
+ size_t valen;
|
||||||
enum data_to_rfc822_error error;
|
enum data_to_rfc822_error error;
|
||||||
|
|
||||||
for (i=0; i<db->n_mboxen; i++) {
|
for (i=0; i<db->n_mboxen; i++) {
|
||||||
diff -ruN t/mairix-0.22/rfc822.c mairix/mairix-0.22/rfc822.c
|
diff --git a/reader.c b/reader.c
|
||||||
--- t/mairix-0.22/rfc822.c 2010-06-05 14:41:10.000000000 -0700
|
index 71ac5bd..18f0108 100644
|
||||||
+++ mairix/mairix-0.22/rfc822.c 2015-07-08 13:30:59.388133879 -0700
|
--- a/reader.c
|
||||||
@@ -1250,7 +1250,7 @@
|
+++ b/reader.c
|
||||||
|
@@ -81,7 +81,8 @@ static void read_toktable2_db(char *data, struct toktable2_db *toktable, int sta
|
||||||
|
/*}}}*/
|
||||||
|
struct read_db *open_db(char *filename)/*{{{*/
|
||||||
|
{
|
||||||
|
- int fd, len;
|
||||||
|
+ int fd;
|
||||||
|
+ size_t len;
|
||||||
|
char *data;
|
||||||
|
struct stat sb;
|
||||||
|
struct read_db *result;
|
||||||
|
diff --git a/reader.h b/reader.h
|
||||||
|
index 9b5dfa3..d709cc4 100644
|
||||||
|
--- a/reader.h
|
||||||
|
+++ b/reader.h
|
||||||
|
@@ -138,7 +138,7 @@ struct toktable2_db {/*{{{*/
|
||||||
|
struct read_db {/*{{{*/
|
||||||
|
/* Raw file parameters, needed later for munmap */
|
||||||
|
char *data;
|
||||||
|
- int len;
|
||||||
|
+ size_t len;
|
||||||
|
|
||||||
|
/* Pathname information */
|
||||||
|
int n_msgs;
|
||||||
|
diff --git a/rfc822.c b/rfc822.c
|
||||||
|
index b411f85..9c8e1a4 100644
|
||||||
|
--- a/rfc822.c
|
||||||
|
+++ b/rfc822.c
|
||||||
|
@@ -990,7 +990,7 @@ static void scan_status_flags(const char *s, struct headers *hdrs)/*{{{*/
|
||||||
|
|
||||||
|
/*{{{ data_to_rfc822() */
|
||||||
|
struct rfc822 *data_to_rfc822(struct msg_src *src,
|
||||||
|
- char *data, int length,
|
||||||
|
+ char *data, size_t length,
|
||||||
|
enum data_to_rfc822_error *error)
|
||||||
|
{
|
||||||
|
struct rfc822 *result;
|
||||||
|
@@ -1265,7 +1265,7 @@ static struct ro_mapping *add_ro_cache(const char *filename, int fd, size_t len)
|
||||||
}
|
}
|
||||||
#endif /* USE_GZIP_MBOX || USE_BZIP_MBOX */
|
#endif /* USE_GZIP_MBOX || USE_BZIP_MBOX */
|
||||||
|
|
||||||
-void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{{*/
|
-void create_ro_mapping(const char *filename, unsigned char **data, int *len)/*{{{*/
|
||||||
+void create_ro_mapping(const char *filename, unsigned char **data, size_t *len)/*{{{*/
|
+void create_ro_mapping(const char *filename, unsigned char **data, size_t *len)/*{{{*/
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
int fd;
|
int fd;
|
||||||
@@ -1371,7 +1371,7 @@
|
@@ -1386,7 +1386,7 @@ comp_error:
|
||||||
data_alloc_type = ALLOC_MMAP;
|
data_alloc_type = ALLOC_MMAP;
|
||||||
}
|
}
|
||||||
/*}}}*/
|
/*}}}*/
|
||||||
@ -57,8 +98,8 @@ diff -ruN t/mairix-0.22/rfc822.c mairix/mairix-0.22/rfc822.c
|
|||||||
+void free_ro_mapping(unsigned char *data, size_t len)/*{{{*/
|
+void free_ro_mapping(unsigned char *data, size_t len)/*{{{*/
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@@ -1399,7 +1399,7 @@
|
@@ -1414,7 +1414,7 @@ static struct msg_src *setup_msg_src(char *filename)/*{{{*/
|
||||||
/*}}}*/
|
/*}}}*/
|
||||||
struct rfc822 *make_rfc822(char *filename)/*{{{*/
|
struct rfc822 *make_rfc822(char *filename)/*{{{*/
|
||||||
{
|
{
|
||||||
@ -66,11 +107,12 @@ diff -ruN t/mairix-0.22/rfc822.c mairix/mairix-0.22/rfc822.c
|
|||||||
+ size_t len;
|
+ size_t len;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
struct rfc822 *result;
|
struct rfc822 *result;
|
||||||
|
|
||||||
diff -ruN t/mairix-0.22/search.c mairix/mairix-0.22/search.c
|
diff --git a/search.c b/search.c
|
||||||
--- t/mairix-0.22/search.c 2010-06-05 14:41:10.000000000 -0700
|
index 18b51ee..97967bc 100644
|
||||||
+++ mairix/mairix-0.22/search.c 2015-07-08 13:32:25.809888610 -0700
|
--- a/search.c
|
||||||
@@ -667,7 +667,7 @@
|
+++ b/search.c
|
||||||
|
@@ -681,7 +681,7 @@ static void mbox_terminate(const unsigned char *data, int len, FILE *out)/*{{{*/
|
||||||
static void append_file_to_mbox(const char *path, FILE *out)/*{{{*/
|
static void append_file_to_mbox(const char *path, FILE *out)/*{{{*/
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -79,8 +121,8 @@ diff -ruN t/mairix-0.22/search.c mairix/mairix-0.22/search.c
|
|||||||
create_ro_mapping(path, &data, &len);
|
create_ro_mapping(path, &data, &len);
|
||||||
if (data) {
|
if (data) {
|
||||||
fprintf(out, "From mairix@mairix Mon Jan 1 12:34:56 1970\n");
|
fprintf(out, "From mairix@mairix Mon Jan 1 12:34:56 1970\n");
|
||||||
@@ -683,8 +683,8 @@
|
@@ -698,8 +698,8 @@ static int had_failed_checksum;
|
||||||
|
|
||||||
static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/
|
static void get_validated_mbox_msg(struct read_db *db, int msg_index,/*{{{*/
|
||||||
int *mbox_index,
|
int *mbox_index,
|
||||||
- unsigned char **mbox_data, int *mbox_len,
|
- unsigned char **mbox_data, int *mbox_len,
|
||||||
@ -90,16 +132,16 @@ diff -ruN t/mairix-0.22/search.c mairix/mairix-0.22/search.c
|
|||||||
{
|
{
|
||||||
/* msg_data==NULL if checksum mismatches */
|
/* msg_data==NULL if checksum mismatches */
|
||||||
unsigned char *start;
|
unsigned char *start;
|
||||||
@@ -715,7 +715,7 @@
|
@@ -738,7 +738,7 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out)
|
||||||
{
|
{
|
||||||
/* Need to common up code with try_copy_to_path */
|
/* Need to common up code with try_copy_to_path */
|
||||||
unsigned char *mbox_start, *msg_start;
|
unsigned char *mbox_start, *msg_start;
|
||||||
- int mbox_len, msg_len;
|
- int mbox_len, msg_len;
|
||||||
+ size_t mbox_len, msg_len;
|
+ size_t mbox_len, msg_len;
|
||||||
int mbox_index;
|
int mbox_index;
|
||||||
|
|
||||||
get_validated_mbox_msg(db, msg_index, &mbox_index, &mbox_start, &mbox_len, &msg_start, &msg_len);
|
get_validated_mbox_msg(db, msg_index, &mbox_index, &mbox_start, &mbox_len, &msg_start, &msg_len);
|
||||||
@@ -735,7 +735,7 @@
|
@@ -759,7 +759,7 @@ static void append_mboxmsg_to_mbox(struct read_db *db, int msg_index, FILE *out)
|
||||||
static void try_copy_to_path(struct read_db *db, int msg_index, char *target_path)/*{{{*/
|
static void try_copy_to_path(struct read_db *db, int msg_index, char *target_path)/*{{{*/
|
||||||
{
|
{
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@ -108,3 +150,12 @@ diff -ruN t/mairix-0.22/search.c mairix/mairix-0.22/search.c
|
|||||||
int mbi;
|
int mbi;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
unsigned char *start;
|
unsigned char *start;
|
||||||
|
@@ -1214,7 +1214,7 @@ static int do_search(struct read_db *db, char **args, char *output_path, int sho
|
||||||
|
unsigned int mbix, msgix;
|
||||||
|
int start, len, after_end;
|
||||||
|
unsigned char *mbox_start, *msg_start;
|
||||||
|
- int mbox_len, msg_len;
|
||||||
|
+ size_t mbox_len, msg_len;
|
||||||
|
int mbox_index;
|
||||||
|
|
||||||
|
start = db->mtime_table[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user