mirror of
https://github.com/eddyem/astrovideoguide_v3.git
synced 2026-03-20 00:31:01 +03:00
remove bug with sockets: write->send(..., MSG_NOSIGNAL)
This commit is contained in:
0
LocCorr/DEBUG.log.analyze
Normal file → Executable file
0
LocCorr/DEBUG.log.analyze
Normal file → Executable file
@@ -27,6 +27,10 @@
|
||||
#define OMP_FOR(x) _Pragma(Stringify(omp parallel for x))
|
||||
#endif
|
||||
|
||||
#ifdef THREAD_NUMBER
|
||||
#define OMP_NUM_THREADS THREAD_NUMBER
|
||||
#endif
|
||||
|
||||
typedef uint8_t Imtype; // maybe float or double only
|
||||
|
||||
typedef struct{
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifdef OMP_FOUND
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <signal.h> // signal
|
||||
@@ -112,6 +116,11 @@ static InputType chk_inp(const char *name){
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
initial_setup();
|
||||
#ifdef OMP_FOUND
|
||||
int cpunumber = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
if(omp_get_max_threads() != cpunumber)
|
||||
omp_set_num_threads(cpunumber);
|
||||
#endif
|
||||
char *self = strdup(argv[0]);
|
||||
GP = parse_args(argc, argv);
|
||||
if(GP->throwpart < 0. || GP->throwpart > 0.99){
|
||||
|
||||
@@ -219,14 +219,14 @@ static char *processCommand(const char msg[BUFLEN], char *ans, int anslen){
|
||||
*/
|
||||
static size_t send_data(int sock, const char *textbuf){
|
||||
ssize_t Len = strlen(textbuf);
|
||||
if(Len != write(sock, textbuf, Len)){
|
||||
if(Len != send(sock, textbuf, Len, MSG_NOSIGNAL)){
|
||||
WARN("write()");
|
||||
LOGERR("send_data(): write() failed");
|
||||
return 0;
|
||||
}else{
|
||||
LOGDBG("send_data(): sent '%s'", textbuf);
|
||||
}
|
||||
if(textbuf[Len-1] != '\n') Len += write(sock, "\n", 1);
|
||||
if(textbuf[Len-1] != '\n') Len += send(sock, "\n", 1, MSG_NOSIGNAL);
|
||||
return (size_t)Len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user