Closed pranomostro closed 7 years ago
The issue seems to go deeper than I initially thought. It looks like ratox can handle friend requests at the moment, but it can't send/receive messages/status/name.
Note that this only holds true when ratox is run over a network, not when run locally. However, it looks like the non-local behaviour is visible locally when ratox is compiled with -O2 (I think).
This is an endianness problem, and is related to https://github.com/TokTok/c-toxcore/issues/205.
Please note that I was having troubles getting correct friend requests between two Little Endian machines (ratox / cyanide). With two local ratox instance, there was no issue.
The following patch helped me fix the friend request issue, but it is platform dependent (depends on endianness), and might break other features that were previously working (I had to rename the shutdown()
function to avoid collisions in arpa/inet.h).
diff --git a/ratox.c b/ratox.c
index 961543b..3c14b11 100644
--- a/ratox.c
+++ b/ratox.c
@@ -1,4 +1,6 @@
/* See LICENSE file for copyright and license details. */
+#include <arpa/inet.h>
+
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -223,7 +225,7 @@ static void friendload(void);
static void frienddestroy(struct friend *);
static void loop(void);
static void initshutdown(int);
-static void shutdown(void);
+static void toxshutdown(void);
static void usage(void);
#define FD_APPEND(fd) do { \
@@ -1603,7 +1605,7 @@ setnospam(void *data)
}
}
- nsval = strtoul((char *)nospam, NULL, 16);
+ nsval = htonl(strtoul((char *)nospam, NULL, 16));
tox_self_set_nospam(tox, nsval);
datasave();
logmsg("Nospam > %08X\n", nsval);
@@ -1909,7 +1911,7 @@ initshutdown(int sig)
}
static void
-shutdown(void)
+toxshutdown(void)
{
struct friend *f, *ftmp;
struct request *r, *rtmp;
@@ -2016,6 +2018,6 @@ main(int argc, char *argv[])
localinit();
friendload();
loop();
- shutdown();
+ toxshutdown();
return 0;
}
Okay, great! I think we'll go with your version until something breaks.
I will just have to apply your patch tomorrow.
Have to find out which one of these causes the problem. Maybe it's an optimization that it reads fifos not line, but buffer-wise.