* enable cross compile srndv2
* fix up kqueue code in nntpchan-daemon
This commit is contained in:
parent
8bd528aa50
commit
cb41b06cb7
@ -1,4 +1,5 @@
|
|||||||
#include <nntpchan/event.hpp>
|
#include <nntpchan/event.hpp>
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
|
|
||||||
namespace nntpchan
|
namespace nntpchan
|
||||||
@ -24,7 +25,7 @@ namespace ev
|
|||||||
|
|
||||||
virtual bool TrackConn(ev::io * handler)
|
virtual bool TrackConn(ev::io * handler)
|
||||||
{
|
{
|
||||||
kevent event;
|
struct kevent event;
|
||||||
short filter = 0;
|
short filter = 0;
|
||||||
if(handler->readable() || handler->acceptable())
|
if(handler->readable() || handler->acceptable())
|
||||||
{
|
{
|
||||||
@ -48,7 +49,7 @@ namespace ev
|
|||||||
|
|
||||||
virtual void UntrackConn(ev::io * handler)
|
virtual void UntrackConn(ev::io * handler)
|
||||||
{
|
{
|
||||||
kevent event;
|
struct kevent event;
|
||||||
short filter = 0;
|
short filter = 0;
|
||||||
if(handler->readable() || handler->acceptable())
|
if(handler->readable() || handler->acceptable())
|
||||||
{
|
{
|
||||||
@ -60,8 +61,7 @@ namespace ev
|
|||||||
}
|
}
|
||||||
EV_SET(&event, handler->fd, filter, EV_DELETE, 0, 0, handler);
|
EV_SET(&event, handler->fd, filter, EV_DELETE, 0, 0, handler);
|
||||||
int ret = kevent(kfd, &event, 1, nullptr, 0, nullptr);
|
int ret = kevent(kfd, &event, 1, nullptr, 0, nullptr);
|
||||||
if(ret == -1) return false;
|
if(ret == -1 || event.flags & EV_ERROR)
|
||||||
if(event.flags & EV_ERROR)
|
|
||||||
{
|
{
|
||||||
std::cerr << "KqueueLoop::UntrackConn() kevent failed: " << strerror(event.data) << std::endl;
|
std::cerr << "KqueueLoop::UntrackConn() kevent failed: " << strerror(event.data) << std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -72,8 +72,8 @@ namespace ev
|
|||||||
|
|
||||||
virtual void Run()
|
virtual void Run()
|
||||||
{
|
{
|
||||||
kevent events[512];
|
struct kevent events[512];
|
||||||
kevent * ev;
|
struct kevent * event;
|
||||||
io * handler;
|
io * handler;
|
||||||
int ret, idx;
|
int ret, idx;
|
||||||
do
|
do
|
||||||
@ -84,17 +84,17 @@ namespace ev
|
|||||||
{
|
{
|
||||||
while(idx < ret)
|
while(idx < ret)
|
||||||
{
|
{
|
||||||
ev = &events[idx++];
|
event = &events[idx++];
|
||||||
handler = static_cast<io *>(ev->udata);
|
handler = static_cast<io *>(ev->udata);
|
||||||
if(ev->flags & EV_EOF)
|
if(event->flags & EV_EOF)
|
||||||
{
|
{
|
||||||
handler->close();
|
handler->close();
|
||||||
delete handler;
|
delete handler;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(ev->filter & EVFILT_READ && handler->acceptable())
|
if(event->filter & EVFILT_READ && handler->acceptable())
|
||||||
{
|
{
|
||||||
int backlog = ev->data;
|
int backlog = event->data;
|
||||||
while(backlog)
|
while(backlog)
|
||||||
{
|
{
|
||||||
handler->accept();
|
handler->accept();
|
||||||
@ -102,10 +102,10 @@ namespace ev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ev->filter & EVFILT_READ && handler->readable())
|
if(event->filter & EVFILT_READ && handler->readable())
|
||||||
{
|
{
|
||||||
int readed = 0;
|
int readed = 0;
|
||||||
int readnum = ev->data;
|
int readnum = event->data;
|
||||||
while(readnum > sizeof(readbuf))
|
while(readnum > sizeof(readbuf))
|
||||||
{
|
{
|
||||||
int r = handler->read(readbuf, sizeof(readbuf));
|
int r = handler->read(readbuf, sizeof(readbuf));
|
||||||
@ -126,9 +126,9 @@ namespace ev
|
|||||||
readed = r;
|
readed = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ev->filter & EVFILT_WRITE && handler->writable())
|
if(event->filter & EVFILT_WRITE && handler->writeable())
|
||||||
{
|
{
|
||||||
int writespace = ev->data;
|
int writespace = event->data;
|
||||||
int written = handler->write(writespace);
|
int written = handler->write(writespace);
|
||||||
if(written > 0)
|
if(written > 0)
|
||||||
{
|
{
|
||||||
|
@ -2,13 +2,15 @@ GOROOT ?= $(shell go env GOROOT)
|
|||||||
GO ?= $(GOROOT)/bin/go
|
GO ?= $(GOROOT)/bin/go
|
||||||
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
REPO=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||||
VERSION=$(shell $(GO) version | cut -d' ' -f3)
|
VERSION=$(shell $(GO) version | cut -d' ' -f3)
|
||||||
|
GOARCH ?= $(shell go env GOARCH)
|
||||||
|
GOOS ?= $(shell go env GOOS)
|
||||||
|
GOARM ?= $(shell go env GOARM)
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
build: srndv2
|
build: srndv2
|
||||||
|
|
||||||
srndv2:
|
srndv2:
|
||||||
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -v
|
GOARM=$(GOARM) GOOS=$(GOOS) GOARCH=$(GOARCH) GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -v
|
||||||
|
|
||||||
srndv2-lua:
|
srndv2-lua:
|
||||||
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -tags lua -v
|
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -tags lua -v
|
||||||
|
Reference in New Issue
Block a user