Giter Club home page Giter Club logo

Comments (4)

xupeilin avatar xupeilin commented on May 30, 2024

能仔细描述下用法和现象吗

from tera.

appleprince88 avatar appleprince88 commented on May 30, 2024

就是在子进程中调用tera的接口,会出现如题中的问题,我举个例子吧,代码如下:


#include 
#include 
#include 
#include 
#include 
#include 
#include "tera.h"
void fun() { 
    tera::ErrorCode error_code;
    tera::Client* client = tera::Client::NewClient("./tera.flag", &error_code);
    tera::Table* table = client->OpenTable("tera_testxxx", &error_code);
    if (table == NULL) { 
        printf("Open talbe fail:%s \n", strerr(error_code));
    }
    std::string key = "1343423432423";
    tera::RowMutation* mutation = table->NewRowMutation(key);
    mutation->Put("1","1","value1");
    table->ApplyMutation(mutation);
    std::string value;
    table->Get(key, "1", "1", &value, &error_code);
    std::cout << value << std::endl;
    delete table;
    delete client; 
    
}
int main() {
    pid_t pid;
    pid = fork(); 
    if (pid > 0) {
        pid_t child_pid;
        int stat_val;
        child_pid = wait(&stat_val);
        printf("after wait child\n");
    }else if (pid == 0) { 
        printf("this is child\n");
        fun();  
    }else { 
        printf("fork error\n");
    }
    return 0;
}

在fun函数的第三行也就是,打开table,会挂起信号量,gdb查看如下:

Reading symbols from /usr/lib64/libk5crypto.so.3...done.
Loaded symbols for /usr/lib64/libk5crypto.so.3
Reading symbols from /lib64/libresolv.so.2...done.
Loaded symbols for /lib64/libresolv.so.2
Reading symbols from /lib64/libnss_files.so.2...done.
Loaded symbols for /lib64/libnss_files.so.2
Reading symbols from /lib64/libnss_dns.so.2...done.
Loaded symbols for /lib64/libnss_dns.so.2
0x000000302b8089aa in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/tls/libpthread.so.0
(gdb) bt
#0  0x000000302b8089aa in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/tls/libpthread.so.0
#1  0x00007faa61ba4de3 in common::CondVar::Wait (this=0xd4b478, msg=0x0) at ./src/common/mutex.h:127
#2  0x00007faa61bd4dc2 in tera::TableImpl::UpdateTableMeta (this=0xd4b200, err=0x7fff30a96200) at src/sdk/table_impl.cc:1840
#3  0x00007faa61bc9cf1 in tera::TableImpl::OpenInternal (this=0xd4b200, err=0x7fff30a96200) at src/sdk/table_impl.cc:412
#4  0x00007faa61ba0639 in tera::ClientImpl::OpenTable (this=0xd82000, table_name=@0x7fff30a961d0, options=@0x7fff30a96127, err=0x7fff30a96200) at src/sdk/client_impl.cc:278
#5  0x00007faa61ba04b9 in tera::ClientImpl::OpenTable (this=0xd82000, table_name=@0x7fff30a961d0, err=0x7fff30a96200) at src/sdk/client_impl.cc:262
#6  0x00000000004011bd in fun () at mulpro.cpp:13
#7  0x000000000040172f in main () at mulpro.cpp:39

from tera.

00k avatar 00k commented on May 30, 2024

应该跟子进程无关吧,父进程不也是shell的子进程?

from tera.

appleprince88 avatar appleprince88 commented on May 30, 2024

那这个是什么原因导致的呢?

from tera.

Related Issues (20)

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.