-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JMAP PushSubscription #4149
base: master
Are you sure you want to change the base?
JMAP PushSubscription #4149
Conversation
unsigned isverified; | ||
int alive; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reordaring the elements to
struct pushsub_data_new {
const char *mailbox;
const char *id;
const char *subscription;
unsigned rowid;
unsigned isverified;
time_t expires;
int alive;
};
will reduce the data needed for the structure. (but it depends how the struct is used)
#include <time.h>
#include <stdio.h>
#include <stdint.h>
struct pushsub_data {
unsigned rowid;
const char *mailbox;
uint32_t imap_uid;
const char *id;
const char *subscription;
time_t expires;
unsigned isverified;
int alive;
};
struct pushsub_data_new {
const char *mailbox;
const char *id;
const char *subscription;
unsigned rowid;
unsigned isverified;
time_t expires;
int alive;
};
int main() {
printf("%lu\n", sizeof(struct pushsub_data));
printf("%lu\n", sizeof(struct pushsub_data_new));
return 0;
}
prints
$ clang -Wpadded pad.c -o pad && ./pad
pad.c:7:17: warning: padding struct 'struct pushsub_data' with 4 bytes to align 'mailbox' [-Wpadded]
const char *mailbox;
^
pad.c:9:17: warning: padding struct 'struct pushsub_data' with 4 bytes to align 'id' [-Wpadded]
const char *id;
^
pad.c:16:8: warning: padding size of 'struct pushsub_data_new' with 4 bytes to alignment boundary [-Wpadded]
struct pushsub_data_new {
^
3 warnings generated.
56
48
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing struct matches those in the other *_db.h files. I'm not sure we are too worried about 8 bytes
* | ||
*/ | ||
|
||
#include <config.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include "config.h"
? Thus "" instead of <>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing #include matches the other source files
a552b80
to
e833ca2
Compare
e833ca2
to
15277a5
Compare
15277a5
to
d14e638
Compare
c9463ee
to
c781e2b
Compare
5ebe9cb
to
6ed09c3
Compare
6ed09c3
to
ee9b014
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay on a first read, a few nits here and there
fprintf(f, "Message-ID: <%s@%s>\r\n", id, config_servername); | ||
|
||
fputs("Content-Type: application/json; charset=utf-8\r\n", f); | ||
fprintf(f, "Content-Length: %lu\r\n", datalen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler will whinge about %lu
on platforms where size_t
is not unsigned long
, IIRC maybe the BSDs are like this. We have SIZE_T_FMT to deal with it:
fprintf(f, "Content-Length: %lu\r\n", datalen); | |
fprintf(f, "Content-Length: " SIZE_T_FMT "\r\n", datalen); |
fwrite(data, datalen, 1, f); | ||
free(data); | ||
|
||
fclose(f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to check if we've successfully written this file, and bail out if it went wrong?
append_abort(&as); | ||
} | ||
else { | ||
/* Commit the append to the sieve mailbox */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sieve mailbox?
enum { | ||
STMT_SELRSRC, | ||
STMT_SELUID, | ||
STMT_SELMBOX, | ||
STMT_INSERT, | ||
STMT_UPDATE, | ||
STMT_DELETE, | ||
STMT_BEGIN, | ||
STMT_COMMIT, | ||
STMT_ROLLBACK | ||
}; | ||
|
||
#define NUM_STMT 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's 9 of them, not 10?
syslog(LOG_ERR, "IOERROR: failed to open %s (%s)", | ||
mboxname, error_message(r)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOERRORs should use xsyslog
|
||
buf_setcstr(&boxbuf, config_getstring(IMAPOPT_JMAPPUSHSUBSCRIPTIONFOLDER)); | ||
|
||
res = mboxname_user_mbox(userid, buf_cstring(&boxbuf)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be something like res = mboxname_user_mbox(userid, config_getstring(...));
? I don't see what the struct buf gets us here. Maybe it's leftover from an earlier implementation?
Start of JMAP PushSubscription support