Build fix for Windows.

pull/1865/head
Roger Light 5 years ago
parent e8a641c759
commit ff2636b3ae

@ -16,6 +16,11 @@ Contributors:
#include "config.h" #include "config.h"
#ifdef WIN32
/* For rand_s on Windows */
# define _CRT_RAND_S
#endif
#include <assert.h> #include <assert.h>
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
@ -737,21 +742,31 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
void rand_init(void) void rand_init(void)
{ {
#ifndef WIN32
struct tm *ti = NULL; struct tm *ti = NULL;
long ns; long ns;
if(!get_time(&ti, &ns)){ if(!get_time(&ti, &ns)){
srandom(ns); srandom(ns);
} }
#endif
} }
void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties) void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties)
{ {
long r; #ifdef WIN32
unsigned int r = 0;
#else
long r = 0;
#endif
if(cfg->random_filter < 10000){ if(cfg->random_filter < 10000){
#ifdef WIN32
rand_s(&r);
#else
r = random(); r = random();
#endif
if((r%10000) >= cfg->random_filter){ if((r%10000) >= cfg->random_filter){
return; return;
} }

@ -44,10 +44,6 @@ Contributors:
# endif # endif
#endif #endif
#ifdef WITH_BRIDGE
#include <poll.h>
#endif
#include "mosquitto_internal.h" #include "mosquitto_internal.h"
#include "mosquitto_broker.h" #include "mosquitto_broker.h"
#include "mosquitto_plugin.h" #include "mosquitto_plugin.h"

@ -66,6 +66,8 @@ struct cb_helper {
bool found; bool found;
}; };
static enum pwhash hashtype = pw_sha512_pbkdf2;
#ifdef WIN32 #ifdef WIN32
static FILE *mpw_tmpfile(void) static FILE *mpw_tmpfile(void)
{ {
@ -74,7 +76,6 @@ static FILE *mpw_tmpfile(void)
#else #else
static char alphanum[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; static char alphanum[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
static enum pwhash hashtype = pw_sha512_pbkdf2;
static unsigned char tmpfile_path[36]; static unsigned char tmpfile_path[36];
static FILE *mpw_tmpfile(void) static FILE *mpw_tmpfile(void)

@ -59,7 +59,9 @@ static void loop_handle_reads_writes(struct mosquitto_db *db, struct pollfd *pol
static struct pollfd *pollfds = NULL; static struct pollfd *pollfds = NULL;
static int pollfd_max; static int pollfd_max;
#ifndef WIN32
static sigset_t my_sigblock; static sigset_t my_sigblock;
#endif
int mux_poll__init(struct mosquitto_db *db, mosq_sock_t *listensock, int listensock_count) int mux_poll__init(struct mosquitto_db *db, mosq_sock_t *listensock, int listensock_count)
{ {
@ -173,7 +175,9 @@ int mux_poll__handle(struct mosquitto_db *db, mosq_sock_t *listensock, int liste
mosq_sock_t sock; mosq_sock_t sock;
int i; int i;
int fdcount; int fdcount;
#ifndef WIN32
sigset_t origsig; sigset_t origsig;
#endif
#ifndef WIN32 #ifndef WIN32
sigprocmask(SIG_SETMASK, &my_sigblock, &origsig); sigprocmask(SIG_SETMASK, &my_sigblock, &origsig);

Loading…
Cancel
Save