Giter Site home page Giter Site logo

tarscloud / tarstup Goto Github PK

View Code? Open in Web Editor NEW
54.0 4.0 15.0 498 KB

Tars tup protocol

License: BSD 3-Clause "New" or "Revised" License

C 6.91% Makefile 0.21% C# 12.04% Objective-C 61.97% Objective-C++ 0.42% PHP 4.09% Python 9.32% C++ 5.04%
tars-foundation tup microservice tars

tarstup's People

Contributors

hpeiy98 avatar katharineozil avatar ruanshudong avatar surejammy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tarstup's Issues

tup-python发包报错是为啥,ImportError: No module named enum

tup-python
Traceback (most recent call last):
File "Hello.py", line 1, in
from tars.core import tarscore;
File "/data/home/maypeng/tup-python/tup-python/tars/core.py", line 89, in
from __rpc import Communicator
File "/data/home/maypeng/tup-python/tup-python/tars/__rpc.py", line 35, in
from __adapterproxy import AdapterProxyManager
File "/data/home/maypeng/tup-python/tup-python/tars/__adapterproxy.py", line 25, in
from enum import Enum
ImportError: No module named enum

A Issue for Dependent Libraries Collection

If you find any dependent libraries in code but never display its open source license in the License file, please comment on this issue, We will update the License file ASAP.
You also can pull request to the License file and remember to describe in detail ; )

Welcome to contribute!

Does TarsTup support java?

I cannot find TarsTup for java.It looks like do not support java at present.When will it support java?

JString_copy bug: not cosider dest and src overlapping

void JString_copy(char * dest, const char * src, uint32_t len)
{
char * pe = dest + len;
if (dest == NULL || src == NULL || (Int32)len < 0)
return;

    if (dest < src)
    {
            for (; dest != pe; ++dest, ++src)
                    *dest = *src;
    }
    else if (dest > src)  //fix bug:not cosider dest and src overlapping
    {
        char* pe = (char*)dest + len - 1;
        const char* ps = (const char*)src + len - 1;

       while(len-- > 0)
       {
          *pe-- = *ps--;
       }

    }

}

oc版本,解到乱码,jceinputStream里会进断言

在jceinputStream.m里的, 各种断言,建议改成抛错处理,至少程序不会崩溃

  • (NSNumber *)readNumber:(int)tag required:(BOOL)required
    {
    [self peakHead];
    if (_headTag != tag)
    {
    assert(required == NO);
    return nil;
    }
    else
    {
    [self readHead];
    switch (_headType)
    {
    case TARS_TYPE_ZERO:
    return [NSNumber numberWithChar:0];
    case TARS_TYPE_INT1:
    return [NSNumber numberWithChar:[self readInt1]];
    case TARS_TYPE_INT2:
    return [NSNumber numberWithShort:[self readInt2]];
    case TARS_TYPE_INT4:
    return [NSNumber numberWithInt:[self readInt4]];
    case TARS_TYPE_INT8:
    return [NSNumber numberWithLongLong:[self readInt8]];
    case TARS_TYPE_FLOAT:
    return [NSNumber numberWithFloat:[self readFloat]];
    case TARS_TYPE_DOUBLE:
    return [NSNumber numberWithDouble:[self readDouble]];
    default:
    assert(0);
    break;
    }
    }
    }

demo main.c bug

  1. testJString & testStruct & testtuppack : sizeof must be strlen;
  2. testtuppack : UniPacket_decode(unpack, buffer, len); must be UniPacket_decode(unpack, buffer + i, len)

TimeoutQueue::timeout only clear timeout request in __data but not __queue

in tup-python:

TimeoutQueue::timeout has a bug that only clears timeout request in __data, but doesn't clear the correspond uniqId in __queue.
Then for TimeoutQueue::pop, may occur that uniqId is already timeout and correspond reqmsg in __data has been cleared. So for code "ret = self.__data.get(uniqId, None)", ret will be None, and TimeoutQueue::pop will return None too.

`

def pop(self, uniqId=0, erase=True):
    '''
    @brief: 弹出item
    @param uniqId: item的id,如果为0,按FIFO弹出
    @type uniqId: int
    @param erase: 弹出后是否从字典里删除item
    @type erase: bool
    @return: item
    @rtype: any type
    '''
    ret = None

    # self.__lock.acquire()
    lock = LockGuard(self.__lock)

    if not uniqId:
        if len(self.__queue):
            uniqId = self.__queue.pop(0)
    if uniqId:
        if erase:
            ret = self.__data.pop(uniqId, None)
        else:
            ret = self.__data.get(uniqId, None)

    # self.__lock.release()

    return ret[0] if ret else None

def timeout(self):
    '''
    @brief: 检测是否有item超时,如果有就删除
    @return: None
    @rtype: None
    '''
    endtime = time.time()
    # self.__lock.acquire()
    lock = LockGuard(self.__lock)

    # 处理异常情况,防止死锁
    try:
        new_data = {}
        for uniqId, item in self.__data.iteritems():
            if endtime - item[1] < self.__timeout:
                new_data[uniqId] = item
            else:
                tarsLogger.debug(
                    'TimeoutQueue:timeout remove id : %d' % uniqId)
        self.__data = new_data
    finally:
        # self.__lock.release()
        pass

`

tup-python main thread and QueueTimeout thread has a race condition for TimeoutQueue::push and TimeoutQueue::timeout

The implementation of NewLock is incorrect. When one thread has get lock, the another thread can't be blocked by it for the incorrect use of __count in newAcquire. The __count shoud use thread local storage and there is no need for __lockForCount.
We can also use RLock to get reentrant mutex lock function.

`
class NewLock(object):
def init(self):
self.__count = 0
self.__lock = Lock()
self.__lockForCount = Lock()
pass

def newAcquire(self):
    self.__lockForCount.acquire()
    self.__count += 1
    if self.__count == 1:
        self.__lock.acquire()
    self.__lockForCount.release()
    pass

`

AttributeError: type object 'struct' has no attribute 'readFrom'

__tars.py 中,在解码时运行到value=coder.readfrom(self)时报错
def __readStruct(self, coder, tag, require, default=None):
if self.__skipToTag(tag):
t, p, l = self.__readFrom()
if p != DataHead.EN_STRUCTBEGIN:
raise TarsTarsDecodeMismatch(
"read 'struct' type mismatch, tag: %d, get type: %d." % (tag, p))
value = coder.readFrom(self)
self.__skipToStructEnd()
return value
elif require:
raise TarsTarsDecodeRequireNotExist(
"require field not exist, tag: %d" % tag)
return default

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.